I am using a droplet as a dev environment for a dockerized application (node, nginx, postgresql, graphql, react). Our docker app sets up an internal network so that different components can communicate with each other. The docker container builds and runs great, but internal calls from the frontend to the backend are getting blocked in the droplet based on CORS errors.
We can run this thing literally everywhere else with no CORS errors - are there droplet-specific settings I need to create?
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!
Hello,
There are no Droplet specific settings. This would happen if the API is running on a different port so that the request origin would not match. Can you share the exact CORS error that you are getting?
You cat add a Access-Control-Allow-Origin to your Node.js app so that it would accept the requests:
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
Let me know how it goes. 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.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.