Pass an options object
// pages/api/auth/[auth0].js
import { handleAuth, handleProfile } from '@auth0/nextjs-auth0';
export default handleAuth({
profile: handleProfile({ refetch: true })
});
Pass a function that receives the request and returns an options object
// pages/api/auth/[auth0].js
import { handleAuth, handleProfile } from '@auth0/nextjs-auth0';
export default handleAuth({
profile: handleProfile((req) => {
return { refetch: true };
})
});
This is useful for generating options that depend on values from the request.
Override the profile handler
import { handleAuth, handleProfile } from '@auth0/nextjs-auth0';
export default handleAuth({
profile: async (req, res) => {
try {
await handleProfile(req, res, { refetch: true });
} catch (error) {
console.error(error);
}
}
});
Use this to customize the default profile handler without overriding it. You can still override the handler if needed.