Code Monkey home page Code Monkey logo

Comments (6)

matthiastjong avatar matthiastjong commented on September 3, 2024

So this seems to be working when I use php artisan serve instead of running it through Docker. However, we really rely on Docker in our workflow. Is this also possible to achieve with docker?

from breeze-nuxt.

JaavierR avatar JaavierR commented on September 3, 2024

I managed to make it work with docker, using 127.0.0.1 instead of localhost on both the front and the back with different ports. But when I log in it returns the error The route dashboard could not be found. or it tells me that I am not authenticated if I ask for the user right after logging in.

from breeze-nuxt.

JaavierR avatar JaavierR commented on September 3, 2024

@matthiastjong I finally make it work with Laravel Sail, but in order to work you need to access the app via http://127.0.0.1 URL instead the localhost.

The following parameters are required:

# .env in the laravel project

FRONTEND_URL=http://127.0.0.1:3000
SESSION_DOMAIN=.127.0.0.1
SANCTUM_STATEFUL_DOMAINS=127.0.0.1:3000

SESSION_DRIVER=cookie
// .env in the nuxt project

NUXT_PUBLIC_BACKEND_URL=http://127.0.0.1
NUXT_PUBLIC_FRONTEND_URL=http://127.0.0.1:3000
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt/config'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  modules: ['@nuxtjs/tailwindcss'],
  runtimeConfig: {
    public: {
      backendUrl: process.env.NUXT_PUBLIC_BACKEND_URL,
      frontendUrl: process.env.NUXT_PUBLIC_FRONTEND_URL
    }
  },
  imports: {
    dirs: ['./utils']
  }
})

And finally when you run the app in dev mode you need to adjust the package.json command to this:

{
...,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --host 127.0.0.1",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
...
}

I hope I have been clear and helpful

from breeze-nuxt.

amrnn90 avatar amrnn90 commented on September 3, 2024

Thanks for sharing what worked out for you @JaavierR !
FYI there is no need to change the runtimeConfig inside nuxt.config.ts as the values there are treated as the defaults and will get overridden if they are defined in your environment variables as long as they adhere to the naming convention NUXT_PUBLIC_ETC.

from breeze-nuxt.

amrnn90 avatar amrnn90 commented on September 3, 2024

Do the settings mentioned above fix your issues with docker @matthiastjong?

from breeze-nuxt.

matthiastjong avatar matthiastjong commented on September 3, 2024

Hi @amrnn90 , we have checked out your solution and it works! Amazing stuff.. After this we can authenticate our local API 😄 Thank you!

from breeze-nuxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.