Based on your video on how to deploy react app with laravel as API, tried to do the same with a Nuxt app.
Added a env variables, absolutely everything 1:1 as is in video except for variable name for react (REACTAPI…), so i got APIBASEURL=${APPURL}/app/api

No matter what i set into this variable, my nuxt app is trying to hit example.com/api/landing
NO ’/app/’ part.
If i try to access to example.com/app/api/landing this does work.

Why is variable not taken in count?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey there!

It looks like you are trying to set routes using env variables. Have you configured any routes in the UI for each component? It does look like this is defaulted to /api. You may also need to configure routes there for your react app if you haven’t done so.

App Platform Routes

Hope it helps!
Nate

  • Hello, thank you.
    I have set equivalent routes in my code as well

    // Project Environment config
      publicRuntimeConfig: {
        APP_NAME: process.env.APP_NAME || 'Agri4All',
        APP_BASE_URL: process.env.APP_BASE_URL || 'http://localhost:3000',
        API_BASE_URL: process.env.API_BASE_URL || 'http://agri-laravel.test/api'
      },
     // Axios module configuration: https://go.nuxtjs.dev/config-axios
      axios: {
        credentials: true,
        proxy: true
      },
      proxy: {
        // Proxy for global api call through this prefix
        '/api/': {
          target: process.env.API_BASE_URL,
          pathRewrite: { '^/api': '/' }
        },
    
        // Proxy endpoint for login, logout, user. That resolved by nuxt-auth-next package.
        '/auth-sanctum': {
          target: process.env.API_BASE_URL,
          pathRewrite: { '^/auth-sanctum': '/' }
        }
      },
    

    Please let me know if you see anything that is wrong in here