Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue cli3 enable CORS

I have had this problem for nearly 2 days, any help would be a life saver.

I have my vue app running on 8080 dev mode and I am trying to integrate blockstack login and that app tries to read http://localhost/manifest.json, so I placed it in static directory, but it is throwing me cors error, do we have solution for that vue cli configurations like vue.config.js?

like image 343
Code Tree Avatar asked Feb 19 '19 11:02

Code Tree


People also ask

Which vue Command inspect and modify the config?

You can edit this file directly with your editor of choice to change the saved options. You can also use the vue config command to inspect or modify the global CLI config.


1 Answers

The "correct answer" doesn't actually help in this instance.

Blockstack needs to be able to hit the manifest.json file (in this case localhost:8080/manifest.json). When the server doesn't support CORS Blockstack will throw an error.

What the OP is asking is how to make "vue-cli-service serve" allow COR requests to happen. To do this, we need to modify Webpack's dev server to allow the CORS request.

Add vue.config.js (if it doesn't already exist)

module.exports = {
  configureWebpack: {
    devServer: {
      headers: { "Access-Control-Allow-Origin": "*" }
    }
  }
};
like image 173
CorbinUX Avatar answered Oct 29 '22 04:10

CorbinUX