Roncho
Roncho7d ago

POST /api/action 404 in 510ms

trying to implement auth with convex, my app is next.js, i'm following a youtube tutorial (AI notes app), and at the end of the auth section, running the signin page and getting this: POST /api/action 404 in 510ms what does that mean, and how to resolve? my convex is running in the background, convex.dev looks green...
9 Replies
Convex Bot
Convex Bot7d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart7d ago
Do you know where the call to /api/action is originating? Almost seems like CONVEX_SITE_URL is being used somewhere that CONVEX_URL is expected Or is /api/action an intentional path to an http action registered in convex/http.ts? Not familiar with the tutorial so any code you can share may shed light.
Roncho
RonchoOP7d ago
@erquhart , thanks! when you hit the sign in button, there is a call to signIn, destructured from useAuthActions, that is imported from import { useAuthActions } from "@convex-dev/auth/react"; that call is causing a post request on /api/action, but physically there is no such folder. some files that might be relevant: auth.ts: import { convexAuth } from "@convex-dev/auth/server"; import { Password } from "@convex-dev/auth/providers/Password"; export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({ providers: [Password], }); http.ts import { httpRouter } from "convex/server"; import { auth } from "./auth"; const http = httpRouter(); auth.addHttpRoutes(http); export default http; auth.config.ts export default { providers: [ { domain: process.env.CONVEX_SITE_URL, applicationID: "convex", }, ], }; .env.local CONVEX_DEPLOYMENT=dev:xxxx NEXT_PUBLIC_CONVEX_URL=https://xxxxx.convex.cloud NEXT_PUBLIC_CONVEX_URL=http://localhost:3000 I can see that process.env.CONVEX_SITE_URL does not exist in my .env, but the tutorial said "it's fine".
erquhart
erquhart7d ago
NEXT_PUBLIC_CONVEX_URL is defined twice Guessing the second one is being honored But the first one is the correct one
Roncho
RonchoOP7d ago
now that i look at it... i have 2 env variables with the same name! yes, you're right
erquhart
erquhart7d ago
/api/action is a call from convex auth to your .cloud deployment url
Roncho
RonchoOP7d ago
ok, got it, let me try
erquhart
erquhart7d ago
That last env var should probably be SITE_URL or NEXT_PUBLIC_SITE_URL (the one that localhost is assigned to)
Roncho
RonchoOP7d ago
wonderful, it works now! thank you so much!

Did you find this page helpful?