by

How to proxy requests using Webpack dev server to avoid cors in development mode

In your webpack.config file add

  
"devServer":{
	"proxy": {
	  "/api": {
		"target": 'https://my-target.com',
		"pathRewrite": { '^/api': '' },
		"changeOrigin": true,
		"secure": false
	  }
	}
}

The above example will proxy the request /api/posts/1
to https://my-target.com/posts/1

Escreva um comentário

Comment