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.

webpack-dev-server proxy dosen't work

See original GitHub issue

I want to proxy /v1/** to http://myserver.com, and here is my devServer configration,

 devServer: {
        historyApiFallBack: true,
        // progress: true,
        hot: true,
        inline: true,
        // https: true,
        // port: 8081,
        contentBase: path.resolve(__dirname,'public'),
        proxy: {
            '/v1/**': {
                target: 'http://api.in.uprintf.com/',
                secure: false
                // changeOrigin: true
            }
        }
    },

but it results in 404 not found error, and here is the response,

Request URL:http://localhost:8080/v1/address/school?keyword=scut&_=1460968888999
Request Method:GET
Status Code:404 Not Found
Remote Address:127.0.0.1:8080
Response Headers
view source
connection:close
content-encoding:gzip
content-type:text/html
date:Mon, 18 Apr 2016 08:41:34 GMT
server:nginx/1.4.6 (Ubuntu)
transfer-encoding:chunked
X-Powered-By:Express

It seems to proxy to my ubuntu nginx server, since i use mac os locally, but i don’t use express in my remote server.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:39 (4 by maintainers)

github_iconTop GitHub Comments

76reactions
Authorlovecommented, Apr 20, 2016

when i set proxy option: changeOrigin: true, it works. From the node-http-proxy’s document, it says,
‘changeOrigin: true/false, Default: false - changes the origin of the host header to the target URL’. Does the changeOrigin option depend on the remote backend server framework?

58reactions
bivvocommented, Aug 31, 2016

@pgangwani Try this. Was able to get this to run.

proxy:{
      '/api/*' : {
        target: 'http://jsonplaceholder.typicode.com/', 
        changeOrigin: true,
        pathRewrite: {
        '^/api': ''
        }
      }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

devServer proxy not working · Issue #793 - GitHub
devServer proxy doesn't proxy. If the current behavior is a bug, please provide the steps to reproduce. Client server running at localhost:8080 ...
Read more >
Webpack 5 Dev Server proxy seems to be ignored
After upgrading to webpack 5, everything seems fine except the dev server proxy. Its like whatever values I put in there are just...
Read more >
DevServer - webpack
DevServer. webpack-dev-server can be used to quickly develop an application. See the development guide to get started. This page describes the options that ......
Read more >
webpack-dev-server - npm
--no-history-api-fallback Disallows to proxy requests through a specified index page. --host <value> Allows to specify a hostname to use. --hot ...
Read more >
Development Server - SurviveJS
webpack-dev-server (WDS) is the officially maintained development server running ... but it's worth trying out if the file watching doesn't work for you....
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