Daniel
01/26/2022, 1:17 AMAccess to fetch at '<https://audette.on.gooddata.com/gdc/account/profile/current>' from origin '<http://localhost:3000>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
In order to attempt to fix this, I followed the instructions here and set up a setupProxy.js
(see below) and made sure to yarn add http-proxy-middleware
I made some modifications to the sample proxy, replacing proxy
with createProxyMiddleware
and replacing <http://secure.gooddata.com|secure.gooddata.com>
with <http://audette.on.gooddata.com|audette.on.gooddata.com>
, but am still getting the error. Does anyone know how to make this work on localhost?
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function (app) {
app.use(createProxyMiddleware("/gdc", {
"changeOrigin": true,
"cookieDomainRewrite": "localhost",
"secure": false,
"target": "<https://audette.on.gooddata.com>",
"headers": {
"host": "<http://audette.on.gooddata.com|audette.on.gooddata.com>",
"origin": null
},
"onProxyReq": function(proxyReq, req, res) {
proxyReq.setHeader("accept-encoding", "identity")
}
}));
app.use(createProxyMiddleware("/*.html", {
"changeOrigin": true,
"secure": false,
"target": "<https://audette.on.gooddata.com>"
}));
app.use(createProxyMiddleware("/packages/*.{js,css}", {
"changeOrigin": true,
"secure": false,
"target": "<https://audette.on.gooddata.com>"
}));
};
Jiri Zajic
01/26/2022, 2:12 AM<http://audette.on.gooddata.com|audette.on.gooddata.com>
. This way you won't need to worry about proxy at all.Martin Burian
01/26/2022, 7:10 AMAndy
01/26/2022, 10:49 AMDaniel
01/26/2022, 8:59 PM