When I look to see what initiates the call, its the use-user.js hook within the Auth0 code. This is the code:
"use client";
import useSWR from "swr";
export function useUser() {
const { data, error, isLoading } = useSWR(process.env.NEXT_PUBLIC_PROFILE_ROUTE || "/auth/profile", (...args) => fetch(...args).then((res) => {
if (!res.ok) {
throw new Error("Unauthorized");
}
return res.json();
}));
// if we have the user loaded via the provider, return it
if (data) {
return {
user: data,
isLoading: false,
error: null
};
}
if (error) {
return {
user: null,
isLoading: false,
error
};
}
return {
user: data,
isLoading,
error
};
}
When I’m logged in it’s not really a problem. But when I’m not, it clogs up my logs with a 404 error. Is this expected behavior? The only thing I can think of is I set up my middleware wrong, but I followed the quick start.
import { NextRequest } from "next/server"
import { auth0 } from "./lib/auth0"
const GUEST_SECRET = process.env.GUEST_SECRET!
const secret = new TextEncoder().encode(GUEST_SECRET)
export async function middleware(request: NextRequest) {
const response = await auth0.middleware(request)
return response
}
export const config = {
matcher: [
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
],
}