Vuejs Application Deploy in Vercel - Error 405

Asked

Viewed 124 times

0

You guys talking blz? I’m having problems deploying my nuxtjs application to Vercel https://vercel.com/ my problem is that when I make a POST request to my api that is configured in the project (below nuxt.config.js) returns me an error 405. I tried to configure the headers with vercel.json as documentation but could not succeed.

nuxt.config.js

modules: [ 
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/auth',
'@nuxtjs/proxy'
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
   proxy: true,
   baseUrl: process.env.ENDPOINT_API
},

proxy: {
   '/api/': { target: process.env.ENDPOINT_API, pathRewrite: { '^/api/': '' } }
},

vercel.json

{
  "headers": [
    {
      "source": "/(.*)", 
      "headers": [
        { "key": "Access-Control-Allow-Credentials", "value": "false" },
        { "key": "Access-Control-Allow-Origin", "value": "*" },
        { "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
        { "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
      ]
    }
  ],
  "env": {
    "ENDPOINT_API":"aqui vai a url da api"
  } 
}
  • Do curl -X OPTIONS aqui_vai_a_url_da_api and check which HTTP verbs are available.

  • HTTP Status 405 means that you are calling a Resource with an unavailable verb, it checks that the url that is doing the POST is right.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.