Anima
Anima
WWasp-lang
Created by Anima on 8/20/2024 in #đŸ™‹questions
Create API endpoint for external service
I want to create an endpoint for an external service to trigger an update to a DB entry. I only want to allow this particular service to use the endpoint, but If the incoming request has an "authorization" header, it's rejected by some middleware with the message '{"message":"Invalid credentials","data":{}}% '. How can I bypass this middleware?
10 replies
WWasp-lang
Created by Anima on 8/6/2024 in #đŸ™‹questions
Auth hooks not triggering
Hi everyone! BE engineer dipping my toes in web dev thanks to Wasp. Struggling to implement an OnAfterSignup hook based on the 0.14.0 release instructions, but my hook isn't triggered on signup. Here's my code:
# main.wasp
...
auth: {
userEntity: User,
methods: {
email: {
...
},
google: {
...
},
},
...
onAfterSignup: import { onAfterSignup } from "@src/auth/hooks.ts",
},
...
# main.wasp
...
auth: {
userEntity: User,
methods: {
email: {
...
},
google: {
...
},
},
...
onAfterSignup: import { onAfterSignup } from "@src/auth/hooks.ts",
},
...
# app/src/auth/hooks.ts (new file)
import type { OnAfterSignupHook } from 'wasp/server/auth';

export const onAfterSignup: OnAfterSignupHook = async ({ providerId, user, oauth, prisma, req }) => {
console.log('onAfterSignup hook triggered');
};
# app/src/auth/hooks.ts (new file)
import type { OnAfterSignupHook } from 'wasp/server/auth';

export const onAfterSignup: OnAfterSignupHook = async ({ providerId, user, oauth, prisma, req }) => {
console.log('onAfterSignup hook triggered');
};
I then sign up using gmail. Sign up succeeds and I'm logged in, but my hook isn't triggered: - No "onAfterSignup hook triggered" was logged to the console - I see a "GET http://localhost:3001/auth/me 401 (Unauthorized)" in the console, which includes a frame "queryFn @ hooks.ts:32" (this is .wasp/out/sdk/wasp/client/operations/hooks.ts) Checked/Tried: [x] User doesn't exist in the database already - though I'm using the same email address multiple times, could that cause the hook to not be triggered? [x] Using the different signature shown in the X post - though not sure why the signature is different [x] Signed up with email/password instead of gmail - same result [x] I have the correct Wasp version (0.14.0) Am I missing something? Many thanks in advance, any help is appreciated đŸ™‚
11 replies