danielkellyio/awake-template

CORs problem with custom domain

Closed this issue · 1 comments

When i got my custom domain on netlify, all the lazy loading stuff stopped working.. The console says CORs problem:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://customdomain.com/api/posts/page-1.json. (Reason: CORS request did not succeed).

Since the DNS is still propagating, i can't actually test with my domain.. but it should work with the domain.netlify.app either right?

TLDR: Add an the environment variable "URL" in the netlify dashboard (as in netlify docs): and give it the value of https://[domain-where-i-visit-my-site.com]

the template can only support a single domain at a time. Under the hood the lazy loading stuff relies on the nuxt axios module to make ajax requests. The nuxt axios module takes a baseURL (see docs) and the awake template passes the URL environment variable as the baseURL. Usually Netlify automatically provides this environment variable set to your current site domain (with protocol) but sometimes when switching domains, I've found it gets a little confused. To be sure it's set to the desired value you can just manually set the environment variable URL in the netllify dashboard to the same base url as the site is available at.