[Vuejs]-"Authorization": token does not pass CORS VUEJS APACHE

-1πŸ‘

βœ…

Hi guys I fixed doing couple changes

first I add this one in my vue.config.js
if you want to build and deploy you just need to uncomment first one to server and second one to local environment

    devServer: {
        //proxy: "https://subdomain.example.com/" 
        //proxy: "http://localhost/" // run in local
    },

Second
In your server I add the htaccess this one:

<IfModule mod_headers.c>
    SetEnvIf Origin "http(s)?://(subdomain)\.example\.com$" AccessControlAllowOrigin=$0
    Header set Access-Control-Allow-Origin "*"
    
    
    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
    Header unset Connection
    Header set Connection keep-alive
    
    Header unset Keep-Alive
    Header set Keep-Alive timeout=100,max=500
</IfModule>

Thats it the CORS was fixed

-1πŸ‘

This is the headers that I am using for CORS

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Access-Control-Allow-Methods: PUT, POST, PATCH, DELETE, GET

I don’t know exactly what you are trying to achieve with that .htaccess

Leave a comment