Code Monkey home page Code Monkey logo

Comments (4)

amrnn90 avatar amrnn90 commented on July 29, 2024

I am not using valet, but with my current setup I am unable to reproduce this.
FYI you do not need to set this SANCTUM_STATEFUL_DOMAINS=webapp.domain.test as Sanctum sets it up automatically based on your FRONTEND_URL env variable.

Anyway here is my setup and things are working as expected.

// frontend/.env

NUXT_PUBLIC_BACKEND_URL=http://api.breeze.localhost
NUXT_PUBLIC_FRONTEND_URL=http://webapp.breeze.localhost

// backend/.env

...
APP_URL=http://api.breeze.localhost
FRONTEND_URL=http://webapp.breeze.localhost
SESSION_DOMAIN=.breeze.localhost
...

I am also using caddy as a reverse proxy.
// Caddyfile

http://webapp.breeze.localhost, https://webapp.breeze.localhost {
	reverse_proxy localhost:3000
}

http://api.breeze.localhost, https://api.breeze.localhost {
	reverse_proxy localhost:8000
}

Finally I have this in my OS /etc/hosts file:

127.0.0.1 webapp.breeze.localhost
::1       webapp.breeze.localhost
127.0.0.1 api.breeze.localhost
::1       api.breeze.localhost
20231201110015.mp4

from breeze-nuxt.

carlosvaldesweb avatar carlosvaldesweb commented on July 29, 2024

Thanks for your answer, to reproduce correctly, you need to make an api request to your backend to get Data. In my case i've created a fresh project with nuxt breeze and two files, page1 and page 2.

Page1:

<template>
  <div>
    <div class="text-xl">Hello from page 1</div>
    <NuxtLink to="/page2">Go to Page 2</NuxtLink>
  </div>
</template>

<script lang="ts" setup></script>

<style></style>

Page2:

<template>
  <div>
    <div class="text-xl">Hello from page 2</div>
    <NuxtLink to="/page1">Go to Page1</NuxtLink>
  </div>
</template>

<script lang="ts" setup>
const { data } = useAsyncData("uniqueId", () => {
  return $larafetch("/user/unique-id");
});
</script>

Notice that when i comment the lines with the useAsyncData call, it doesnt create duplicated XSRF Token, and when i make the request to backend, it duplicate the XRSF

Laravel:

APP_URL=http://api.breeze.test
FRONTEND_URL=http://app.breeze.test
SESSION_DOMAIN=.breeze.test

Unique Id method in laravel, only for demonstration purposes:

public function uniqueId(Request $request)
    {
        $user = $request->user();
        $uniqueId = Str::random(8);
        return $uniqueId;
    }
grabacion-de-pantalla-2023-12-01-a-la-s-103022-am_vFZWvLZ2.mp4

from breeze-nuxt.

amrnn90 avatar amrnn90 commented on July 29, 2024

In my demo page1.vue had a useAsyncData() call which provides that {"id": 1} value you see on the page.
I would suggest using localhost:3000 and localhost:8000 for development if possible to avoid running into such weird issues.

from breeze-nuxt.

carlosvaldesweb avatar carlosvaldesweb commented on July 29, 2024

I've tried with localhost:3000 and localhost:8000 and it works correctly. I think that is problem with laravel valet config, maybe the proxy is not working correctly. Thanks for your help @amrnn90

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.