my project is currently using Vue CLI and everything including the deployment via Netlify is working great. Today I wanted to try out to migrate to Vite. I set up everything locally and it worked. I then wanted to make a preview via Netlify but the page did not load because the “main application” was not able to load the desired chunks because of CORS.
For me CORS always only was something on the Backend-Side and I therefore have no real experience with that.
thank your for the response. I should have mentioned that before I opened this issue, I already made some research in the forums and came across your linked thread. I then added a _headers file in my public folder with the following content:
/*
Access-Control-Allow-Origin: *
But that unfortunately didn’t work. Now that you explicity linked that thread as a help I tried the netlify.toml-approach and edited my netlify.toml, now it looks like this
[build]
# ignore all PRs opened by `dependabot` (with last commit made by `dependabot`)
ignore = 'git log -1 --pretty=%B | grep dependabot'
# The following redirect is intended for use with most SPAs that handle
# routing internally.
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[[headers]]
# Define which paths this specific [[headers]] block will cover.
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
But I still receive the same CORS-error. Looking at the netlify build log I see that everything should have worked:
Additionally, visiting the blocked script https://d33wubrfki0l68.cloudfront.net/js/3716626c91e487cf38233945435e03c2b251c18c/assets/vendor.9800afec.js results in CDN object Not Found - Request ID: 631bdb86-02f8-4f17-9e09-308c6356dfc2
this file also exists at /assets/index.b2cd7f4b.js (on your app URL.) Both versions of the file are identical. In them is a single reference to ./vendor.9800afec.js with all other references being /assets/vendor.9800afec.js. When /assets/index.b2cd7f4b.js is loaded from Cloudfront the ./vendor.9800afec.js fails to load because of CORS/404.
which is the local version of the file (for preloading.)
I am unable to speculate on what is happening on Netlify’s side. A Support Engineer will have the resources to comment on that. The possibility of a setting (or settings) that aren’t configured correctly is always a possibility.