webpack dev server CORS issue
Ich benutzewebpack-dev-server v1.10.1
, um mein Redux-Projekt zu verbessern, und ich habe die folgenden Optionen:
contentBase: `http://${config.HOST}:${config.PORT}`,
quiet: false,
noInfo: true,
hot: true,
inline: true,
lazy: false,
publicPath: configWebpack.output.publicPath,
headers: {"Access-Control-Allow-Origin": "*"},
stats: {colors: true}
In der JS verwende ichrequest
vonsuperagent
um einen HTTP GET Aufruf zu generieren
request
.get(config.APIHost + apiUrl)
.set('Accept', 'application/json')
.withCredentials()
.end(function (err, res) {
if (!err && res.body) {
disptach(() => {
return {
type: actionType || GET_DATA,
payload: {
response: res.body
}
}
});
}
});
Aber ich habe den CORS-Fehler erhalten:
XMLHttpRequest cannot load http://localhost:8000/api/getContentByType?category=all. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5050' is therefore not allowed access
Irgendein Vorschlag, dies zu beheben? Danke vielmal