The solution to access problems webpack-dev-server resources across domains

  • Question: In the process of development with vue will be used webpack-dev-serverto build a local staging server, if there is a resource script this time under a different domain wants to access webpack-dev-server will report the following 跨域error.
  • Solution: Open the build/webpack.dev.conf.jsfile and make the following changes:
devServer: {
	//加一行header即可
	headers:{'Access-Control-Allow-Origin':'*'}
}
Published 41 original articles · won praise 4 · Views 3877

Guess you like

Origin blog.csdn.net/weixin_42487874/article/details/104327486