Option to do Client only auth with SSR#1564
Open
alexandresanchograca wants to merge 2 commits intovuejs:mainfrom
Open
Option to do Client only auth with SSR#1564alexandresanchograca wants to merge 2 commits intovuejs:mainfrom
alexandresanchograca wants to merge 2 commits intovuejs:mainfrom
Conversation
… This is because we might want do SSR without server authentication, authentication only on the client, since many firestore data are not restricted by authorization or authentication of a user.
sun
reviewed
Nov 12, 2024
packages/nuxt/src/module.ts
Outdated
|
|
||
| // loads the user on the current app | ||
| addPlugin(resolve(runtimeDir, 'auth/plugin-authenticate-user.server')) | ||
| if(!options.auth.clientOnly){ |
There was a problem hiding this comment.
Suggested change
| if(!options.auth.clientOnly){ | |
| if (!options.auth.clientOnly) { |
Is the key always set on auth?
Author
There was a problem hiding this comment.
The clientOnly key?
If the key is not set it executes the previously default behaviour of loading the auth/plugin-authenticate-user.server.
Formatted code Co-authored-by: Daniel Kudwien <daniel@netzstrategen.com>
|
Wondering if this would solve #1315 (unwanted console warnings on SPA about SSR problem Would be great to get some movement on this if possible to solve the pesky warnings that clutter the console. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In my usage I found it lacked the need to support client only Auth with SSR. Currently I only want to do authentication on the client, but still want to fetch firestore data that doesn't require an authenticated user to be able to retrieve this data on the server.
This change should be compatible with all the old versions without any breaking changes.
To only allow authentication on the client during SSR:
Before this would require an admin service-account to be included in your project so that the app could fetch the server data, with this check we disable the loading of the
plugin-authenticate-user.server, and can start a firebase app on the server without firebaseAuth and retrieve public/accessible data of firestore without needing an authorisation.When on the client the authorisation will remain enabled and the rest of the data that requires authorisation will be loaded client only.