Replies: 4 comments
-
Shouldn't these headers be set on your external API endpoint rather than on the request?
That if your CORS error comes from http://e2esm-sandbox.intel.com. If you call your Express server from an other domain, then you can use cors Theoretically if you have this setup (as you said) This is not an issue with the middleware. |
Beta Was this translation helpful? Give feedback.
-
This error message says it was being redirected. Did you try these appropriate options to handle the http redirects:
Those options should rewrites the protocol/host/port to comply with the CORS policy. Here are some resource on how redirects work: |
Beta Was this translation helpful? Give feedback.
-
Try using the node cors package. I had to use it in mine to avoid CORS errors, here's a snippet `var express = require('express'); var app = express(); |
Beta Was this translation helpful? Give feedback.
-
On your target, try to use https instead |
Beta Was this translation helpful? Give feedback.
-
Is this a question?
So I've got a question about my setup (yes I've looked on StackOverflow and through the other issues). Currently I've got a react app I bootstrapped with create-react-app. When in development, I use the webpack dev server proxy to proxy my API requests to an external API so I don't get hit with CORS errors. This works great locally, but when I build my site for production, I get hit with the CORS errors again.
In production our site is hosted on an Nginx instance, but I'm trying to mimic the webpack proxy behavior to avoid the CORS errors and am trying to use a simple Node.js server with this library.
According to the person who manages the API (not me, someone else in our company), he said that in order to avoid these I need to get it hosted on the same internal domain (website.company.com) which I have, but I still get CORS errors. I talked with someone else on his team and he said I needed to have a server make the requests, not the client (I'm pretty new at this whole web dev thing, I'm just an intern).
I currently have the react site making requests with axios that look like this
and this is how the server.js looks like:
But whenever I try and make a request through the page, I still get a CORS error.
I'm not sure how I can get my expected behavior of the webpack dev server on my production server.
Steps to reproduce
Expected behavior
I expected it to behave such as the webpack-dev-server does with its proxy.
Actual behavior
It doesn't proxy the request and still runs in to CORS errors.
Setup
So the configuration we have in our server.js file looks like this:
client info
Windows
target server info
Externally hosted server on the same network, uses the ServiceNow API.
Beta Was this translation helpful? Give feedback.
All reactions