Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to adapt to external api server? #5

Open
josselinonduty opened this issue Feb 10, 2025 · 0 comments
Open

Question: how to adapt to external api server? #5

josselinonduty opened this issue Feb 10, 2025 · 0 comments

Comments

@josselinonduty
Copy link

josselinonduty commented Feb 10, 2025

I am creating an app based on better-auth and nuxt. This example is very handy.
However, I need to use an external server (including for auth), meaning I changed the baseUrl option in better auth client.

Using this repo I get hydration mismatches and empty sessions on server (since it tries to access server session but it is not on the same server).

For now, here are my attemps:

middelware/auth.global.ts

  • always await fetchSession()

plugins/auth.[env].ts

  • always fetch, in any circumstances --> does nothing

I added this in my middleware:

console.log("loggedIn (before)", user.value?.name);
await fetchSession();
console.log("loggedIn (after)", user.value?.name);

On client, it successfully gets the session (undefined then defined).
However, on server, it always says session in undefined.

Any idea or similar issues that where solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant