amazonaffected
amazonaffected
NNuxt
Created by amazonaffected on 10/18/2024 in #❓・help
How would you implement showing a success message after posting a form?
I have this use case: 1. User navigate to /books/create which displays a form to create a book 2. User fills the from and submits the form 3. In case of a successful submit, the user gets redirected to /books/:id and a success message is shown at the top. Now, I'm not sure how to show the success message and make sure it's only shown once. E.g. it shouldn't appear again when page is refreshed. I'm thinking about using sessionStorage or just simply redirect to /books/:id?success=true and then somehow omit the success query param. What do you think? Are there existing solutions that solve this problem?
6 replies
NNuxt
Created by amazonaffected on 10/15/2024 in #❓・help
Nuxt-auth causing 500 Server Error due to invalid url passed to `new URL`.
What is the callbackUrl property of a SessionRequired error in nuxt-auth supposed to hold? See here: https://github.com/sidebase/nuxt-auth/blob/734953f89bd19192540452d9e0fbb225d01b28c3/src/runtime/middleware/auth.ts#L99
if (authConfig.provider.type === 'authjs') {
const signInOptions: Parameters<typeof signIn>[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.fullPath) }
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore This is valid for a backend-type of `authjs`, where sign-in accepts a provider as a first argument
return signIn(undefined, signInOptions) as ReturnType<typeof navigateToAuthPages>
}
if (authConfig.provider.type === 'authjs') {
const signInOptions: Parameters<typeof signIn>[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.fullPath) }
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore This is valid for a backend-type of `authjs`, where sign-in accepts a provider as a first argument
return signIn(undefined, signInOptions) as ReturnType<typeof navigateToAuthPages>
}
I'm asking because this causing me 500 errors, because the final URL is invalid when passed to new URL. Basically, when I visit http://localhost:3000/welcome and /welcome is protected. The value of callbackUrl is determiend to be "/welcome" (which is the exact same value as to.fullPath, actually it is taken from it). So, I tried to manually set it to include the hostname and proto (e.g. "http://localhost:3000/welcome") but then it causes an infinite redirect to the same page. I've already tried setting up the correct env variables and baseURL but to no avail. The server always throws a 500 Error due to invalid value passed to new URL, but then somehow the client doesn't have this error and redirect to the auth page. More context: * using authjs * using Keycloak provider (only provider). * Already added NUXT_AUTH_ORIGIN=http://localhost:3000 * Already tried with and without baseURL
6 replies
NNuxt
Created by amazonaffected on 10/15/2024 in #❓・help
How to get the error / stack trace causing the 500 errors when pre-rendering?
No description
1 replies
NNuxt
Created by amazonaffected on 10/3/2024 in #❓・help
Prisma Studio asks to be installed in Nuxt DevTools with each reload?
Hello, I installed the nuxt prisma module and now every time I make changes to code it asks me:
Do you want to view and edit your data by installing Prisma Studio in Nuxt DevTools?
Do you want to view and edit your data by installing Prisma Studio in Nuxt DevTools?
And it doesn't seem to remember my previous answer to "Y" yes install. Is there a configuration I can set so that it automatically installs and never ask me?
3 replies