hrutik_k
hrutik_k5mo ago

convexAuth , nextJS google auth getting 404:not found error while click on the signIn

hey @Michal Srb , i am trying to integrate google auth in convex but it's throwing error of 404 not found Things verified by me : 1. middleware is in root folder 2. Im using alpha version of convex auth
No description
6 Replies
sshader
sshader5mo ago
What does your middleware.ts look like?
Arod1207
Arod12075mo ago
I was getting a 404 as well using github and it was such a silly mistake on my part. I misspelled middleware.ts
hrutik_k
hrutik_kOP5mo ago
here
import { convexAuthNextjsMiddleware } from "@convex-dev/auth/nextjs/server";

export default convexAuthNextjsMiddleware();

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
import { convexAuthNextjsMiddleware } from "@convex-dev/auth/nextjs/server";

export default convexAuthNextjsMiddleware();

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
verified this one too spelling is correct
rgz
rgz5mo ago
msg'd you.
hrutik_k
hrutik_kOP4mo ago
bump any clue ? I verified the docs but none of the things are working for me
sshader
sshader4mo ago
Based on those logs it looks like the middleware isn't proxying requests to /api/auth to Convex. I'd try adding logging in the implementation of the middleware (either modify your node modules, delete the .next directory, and rebuild, or copy out enough of the implementation into your own middleware.ts file) So something like
async (request, event) => {
console.log("### middleware", request.url);
const requestUrl = new URL(request.url);
// Proxy signIn and signOut actions to Convex backend
if (requestUrl.pathname === (options?.apiRoute ?? "/api/auth")) {
console.log("#### proxyAuthActionToConvex", requestUrl.pathname);
return await proxyAuthActionToConvex(request, options);
}
async (request, event) => {
console.log("### middleware", request.url);
const requestUrl = new URL(request.url);
// Proxy signIn and signOut actions to Convex backend
if (requestUrl.pathname === (options?.apiRoute ?? "/api/auth")) {
console.log("#### proxyAuthActionToConvex", requestUrl.pathname);
return await proxyAuthActionToConvex(request, options);
}
You should also be able to see what requests are being made by your browser in the "Network" tab of dev tools -- in my working example, I have a request to localhost:3000/api/auth that triggers both of those log lines

Did you find this page helpful?