Comments (4)
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.
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");
});
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.
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.
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)
- How to use $larafetch in server? HOT 6
- It would be cool if you can make this a nuxt module HOT 4
- initCsrf is always called HOT 2
- The guest middleware not working with pinia stores HOT 29
- Redirecting to Login Page on Refresh HOT 2
- [nuxt] [request error] [unhandled] [500] [GET] "http://localhost:8000/api/user": <no response> fetch failed HOT 1
- useLarafetch with async functions inside other composable HOT 4
- Error 500 A composable that requires access to the nuxt instance.... HOT 6
- Being redirected to login page on refresh HOT 8
- useEvent is not defined HOT 1
- npm run build error [nuxt] [request error] [unhandled] [500] useEvent is not defined HOT 6
- Modify schema of login/register/password-reset etc. response
- Improper handling of the session
- useSubmit validationErrors available until nextTick
- Login error on production machine, cors works but I get the error message | "CSRF token mismatch." HOT 1
- There is a csrf problem when calling login via post action on the productions environment.
- $larafetch does not work with the installed "axios": "^0.21.2", from @vercel in your program.
- The developers of this application should please contact me. I need help with the deployment. Your effort will of course be paid... HOT 1
- in $larafetch.ts no cookies can be read out. it is undefined when transferring to the login page, therefore the error message "CSRF token mismatch." HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from breeze-nuxt.