Question

Nuxt js return cors problem in subdomain

Posted September 12, 2021 25 views
NginxPHPVue.jsLaravel

This code working on local but live not work
Nginx

server {
    listen 80;
    listen [::]:80;
    index index.html;
    server_name freeconvertany.com www.freeconvertany.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Access-Control-Allow-Origin *;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

nuxt.config

axios: {
    prefix: '/api',
  },

  proxy: {
    '/api': {
      target: 'http://api.freeconvertany.com/api',
      pathRewrite: {
        '^/api': '/'
      }
    }
  },

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!