Closed arrowtype closed 3 years ago
Maybe this is old, or maybe this is still a problem: for some time, apparently CORS requests from AWS were blocked by Firefox/: https://forums.aws.amazon.com/message.jspa?messageID=160131
How to do this:
buckets
and click on “Buckets S3 feature”arrowtype
) and select a region that you think is closest to you / most of your users*
) to allow subdomains, like https://*.arrowtype.com
. Note that I also include http://localhost:8080
, the URL which my local-development builds get served to.[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"https://*.arrowtype.com",
"https://arrowtype.com",
"http://localhost:8080"
],
"ExposeHeaders": []
}
]
https://arrowtype2.s3.amazonaws.com/name_sans-variable.woff2
.In your CSS, you can use a font’s basic family name in order to just use a local copy of that font. This can make fonts appear more quickly for users, if those users already have that font on their system. However, especially with newer fonts, this may cause problems. How do you know that your users will have the latest version of a font? Often, the OS will serve an unintended font style, even if it does have the latest version.
So, I often make sure to use a name that specifically won’t call a local file. I do this either by removing spaces or adding a suffix like ”VF“.
@font-face {
font-family: 'NameSansVF';
font-weight: 1 1000;
src: url("https://arrowtype.s3-us-west-2.amazonaws.com/name_sans-variable.woff2");
}
html {
font-family: 'NameSansVF', sans-serif;
}
Your font should now work locally and also in deployment. Of course, the only way to know is to deploy the site and test it on a few different devices!
Additionally, the font is (relatively) safe from being directly used on any site that just copies your CSS. You can verify this out by trying it on CodePen, where it shouldn’t work (unless you allow CodePen URLs in your CORS settings).
If you need to update the font version on S3 in the future, you can simply repeat the process of uploading a file.
Just remember to also follow the “Make Public” steps, or things will break!
This is a pretty big problem, but luckily, it’s not too hard to fix.
You can use a tool called BFG to remove them – even GitHub recommends this tool.
--delete-files
option to delete the font filename you’d like to keep private:cd ~/code/blog-11ty # change to the root of your web project
java -jar ~/Downloads/bfg-1.13.2.jar --delete-files name_sans-variable.woff2
git push --force
to force push the edited Git history to your repo.Oh no. -_- There are two significant problems here:
http://localhost:8080
to the CORS allowlist.To be continued...
To potentially add: pricing. But, it appears that this is fractions of a penny per month, unless a site had massive traffic.
https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html#how-do-i-enable-cors