Webpack-dev-server: Cross domain error even after adding header

Created on 3 Jan 2017  路  5Comments  路  Source: webpack/webpack-dev-server

Hi,

I am getting the following error while running the webpack dev server,

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

I have added all the combination of header, proxy. But no luck.

My devserver config look like

devServer: {
contentBase: './',
header: {
'Access-Control-Allow-Origin': 'http://localhost:8080',
'Access-Control-Allow-Methods': 'GET,OPTIONS,HEAD,PUT,POST,DELETE,PATCH',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Authorization, X-Request-With',
'Access-Control-Allow-Credentials': 'true'
}
}

Most helpful comment

I have had the same issues

All 5 comments

It's headers, not header.

Oops typo error, thanks Kluskens .

Hi, I'm having this issue with webpack 2.4.2 and setting the headers didn't help. What else could it be?
Edit: weird thing is that I see the error in the console, but I also see the response correctly in the network tab:

screen shot 2017-04-28 at 9 40 06 am

screen shot 2017-04-28 at 9 40 19 am

I have had the same issues

@Zadvornyi please don't add "me too" replies to an issue. instead, please use the reaction buttons to add a thumbs up to a comment you're agreeing with, or the original post.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gimmi picture gimmi  路  3Comments

tulika21-zz picture tulika21-zz  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

mischkl picture mischkl  路  3Comments

nikirossi picture nikirossi  路  3Comments