Apache + Vue CLI project on localhost

Hi, I have my Vue CLI project on localhsot:3000, and my backend on apache in PHP on localhost:8080, and I need to connect them together on my localhost. CORS is blocking everything. I know this would be a small config change. Could sb help me?

You PHP scripts need to send the „CORS Header“ (Access-Control-Allow-Origin: *), so the browser can allow your Vue‘s JS to access the resource.

I added this header to my backend app and in my FF nwtork section i get ‘CORS error’:

The screenshot suggests that you set the header wrong. You have to set it to „where the browser‘s request comes from“ (localhost:3000) but you set it to „who answers the request“ (localhost:8080).

While you work only local, you might aswell set it to * („allow from everywhere“).

I configured my vue.config.js file:

module.exports = {
devServer: {
    proxy: {
        '/kordrew': {
            target: 'http://localhost:8080',
            changeOrigin: true,
            secure: false
        }
    }
}

}

and now when i try using ex. axios…get(’/kordrew?getImages=true’) - is returning data from backend, but when i try using POST method, ex. axios.post(’/kordrew’) it returning errors:


If I don‘t understand your problem wrong: you need to configure the backend part of your application (your PHP Code), not the Vue (frontend). Your error message seems to be the same as in your previous post.

In addition to the allowed origin, you might also need to configure the allowed methods (also allow POST in your case).