question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CORS issue with "webpack-dev-server": "^1.14.1"

See original GitHub issue

Hi everyone, I’m using:

    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.1",
    "webpack-merge": "^0.8.4"

and I get the following error when I try to hit googleapis:

XMLHttpRequest cannot load http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=8&q=http://rss.cnn.com/rss/edition_entertainment.rss?output=rss. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access.

I have added following settings in webpack.config.js:

// Webpack Config
var webpackConfig = {
  headers: {
    "Access-Control-Allow-Origin": "http://localhost:3000",
    "Access-Control-Allow-Credentials": "true",
    "Access-Control-Allow-Headers": "Content-Type, Authorization, x-id, Content-Length, X-Requested-With",
    "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS"
}

… but I still getting the same error. Can anyone give me some advice please? Thank you for your time.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:23 (5 by maintainers)

github_iconTop GitHub Comments

77reactions
andrerpenacommented, Apr 22, 2017

Today I updated webpack-dev-server from 2.4.1 to 2.4.3 and suddenly HMR stopped working until I added this to my webpack config file:

devServer: {
        headers: {
            'Access-Control-Allow-Origin': '*'
        }
    }
70reactions
Soolancommented, Aug 6, 2016

Thanks @SpaceK33z , I edit the file as follow:

  devServer: {
    historyApiFallback: true,
    watchOptions: { aggregateTimeout: 300, poll: 1000 },
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
      "Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
    }
  },

Still no luck. Your advice is much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack dev server CORS issue - Stack Overflow
CORS is server issue, server does not allow access from different source. Even using different ports is considered to ... "dev-server": "webpack-dev-server ......
Read more >
webpack-dev-server-cors v1.14.3 Bundlephobia
Size of webpack-dev-server-cors v1.14.3 is 712.6 kB (minified), and 272.3 kB when compressed using GZIP. Bundlephobia helps you find the performance impact ...
Read more >
webpack-dev-server-cors vulnerabilities - Snyk
version published direct vulnerabilities 1.14.3 26 Feb, 2016 0. C. 0. H. 0. M. 0. L 1.14.2 26 Feb, 2016 0. C. 0. H. 0....
Read more >
webpack/webpack/dev - Gitter
Hello ! I've been trying to connect to the socket in which webpack-dev-server write the errors / warnings occurring during development. Problem is...
Read more >
Bypassing CORS Error with Webpack Dev Server - Medium
CORS is a way to bypass the SOP enforced by the browser in order to allow fetching scripts or resources from different domains....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found