aio-libs / aiohttp-devtools

dev tools for aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webfonts wasn't rendered in web page that use css and font file serving through runserver command

panuta opened this issue · comments

  • aiohttp-devtools version:
    0.6.4

  • aiohttp version:
    2.3.7

  • python version:
    Python 3.6.3

  • Platform:
    macOS

Issue Summary

Text in web page was rendered using system fonts instead of webfonts that I have specified in css file.

I have checked that all files can be served correctly (got http status 200 or 304).

If i use webfonts library that was served from CDN, text was rendered with webfonts perfectly. This issue was happened only when files was served through adev runserver command.

While digging into this issue, I found that http response headers is different between webfonts file that was served from devtools and from CDN. The main difference is the lacking of Cross Origin Resource Sharing headers in files from devtools. Although I'm not 100% sure that this is the real culprit. I still haven't found a way to inject these headers to response to test my assumption.

Might be that we require Access-Control-Allow-Origin: * on the static server.

Do we need to do this only for specific file types/extensions eg. .*\.(eot|ttf|otf|woff) or can we do it for all files?

If you could create a file with this fix or at least test if that fixes the issue it'd be very helpful.

@samuelcolvin I now can confirm that adding Access-Control-Allow-Origin: * will solve this issue.

I have create a pull request for the fix. Personally I'm more inclined to having Access-Control-Allow-Origin: * headers in every static files, but targeting only webfonts is ok for me too.

Please help me review the fix as my solutions might have any side effect that I'm not aware of.

NOTE: all webfonts file extensions probably is eot|svg|otf|ttf|woff|woff2

@samuelcolvin Would it be ok now to submit a new pypi version with the fix?

Done, sorry for delay.

No problem, Thank you