1

I am running a VUE 3 CLI project on localhost

There is a remote server I need to call for data. Browsers were blocking this CORS so I had to learn how to set up correct api headers and a proxy in the vue config.

My vue.config.js file contains this:

devServer: {
    https: true,
    proxy: {
        '^/api': {
            target: 'https://api.mysite.com/',
            ws: true,
            changeOrigin: true
        }
    }
},

This resolved my CORS block from local host to the remote server but caused the problem in the title. It now thinks that the call to the sockjs-node file is cross origin.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://192.168.29.243:8080/sockjs-node/info?t=1615826901010. (Reason: CORS request did not succeed).

I can't seem to find any reason for this or a solution. Has anyone run into this and knows what to do?

silversunhunter
  • 1,219
  • 2
  • 12
  • 32

1 Answers1

1

This fixed it for me. Please check following link: How can I fix these SockJS ssl errors?

    // vue.config.js
module.exports = {
    devServer: {
        proxy: {
            "^/api": {
                target: "https://localhost:44345",
                ws: true,
                changeOrigin: true,
            },
        },
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
        },
        public: "http://localhost:44345",
        disableHostCheck: true,
    },
};
ItsNotMyFault
  • 110
  • 1
  • 8