Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dany68's avatar
Level 15

Nuxt Axios Proxy not working on Forge

Hi everyone,

I'm struggling since yesterday to make nuxt-axios proxy works. Locally everything is working fine but on the server the axios calls are not proxied. I have a laravel project setup at api.mysite.com and a nuxt project at mysite.com.

// nuxt.config.js
axios: {
    proxy: true,
    credentials: true,
},

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

I've tried various configuration with baseURL, changeOrigin.. nothing seems to work. However i can see that from my local nuxt app the urls are proxied to the server api project.

Thanks a lot for your help,

0 likes
2 replies
User1980's avatar

I to not use NUXT but just checked the doc for you: https://axios.nuxtjs.org/options/

It says:

Note: In the proxy module, /api/ will be added to all requests to the API end point. If you need to remove it use the pathRewrite option:

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

Is is what you want? Do you really want to remove /api/ from your requests?

dany68's avatar
Level 15

Thanks for your reply. Yes this is what I want. For example if my axios call is:

this.$axios.$get('/api/hello').then((res) => res);

// I want to change it to: https://mysite.com/api/v1/hello OR https://api.mysite.com/v1/hello

Locally it take effect but not on the server. Maybe I need to edit forge configuration ?

Please or to participate in this conversation.