By kongkongye
when in dev environment, the origin is http://localhost:5173, it’s ok. when in prod environment, the request origin is chrome-extension://xxxxx, it’s not ok, an cors error occur.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
The problem is that the origin is not recognized by the server as a valid origin, causing the CORS error. In your case, when running in a development environment, the requests are being made from http://localhost:5173, which is a standard origin for local development. However, in a production environment, the requests are being made from a chrome extension, which has an origin of chrome-extension://xxxxx.
To resolve this issue, you’ll need to configure your server to allow requests from the chrome extension origin. You can do this by setting the Access-Control-Allow-Origin header on your server to the value of chrome-extension://xxxxx. Some framework like express have a package to handle CORS:
https://expressjs.com/en/resources/middleware/cors.html
If you are using Nginx, you can follow the steps here:
https://www.digitalocean.com/community/questions/how-do-i-enable-cors-on-ubuntu-20-4-with-nginx
Feel free to share more details on your production setup.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.