cors error when request from chrome extension

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.

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 11, 2023

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:

If you are using Nginx, you can follow the steps here:

Feel free to share more details on your production setup.



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.