Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack-dev-server proxy: context with wildcard

Tags:

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

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 doesn't work, enter image description here

like image 896
Arthur Xu Avatar asked Apr 16 '16 08:04

Arthur Xu


1 Answers

Update: thanks to @chimurai, setting changeOrigin: true is important to make it work.

Underneath webpack-dev-server passes all the proxy configuration to http-proxy-middleware, from the documentation. It's clear the use case you want is actually achieved with /v1/** path:

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      }    }  }, 
like image 163
Yevgen Safronov Avatar answered Oct 05 '22 04:10

Yevgen Safronov