Redirect to custom error page

throw new APIError("FORBIDDEN", {
code: "FORBIDDEN",
message: "Access denied. This application is currently in maintenance mode.",
});
throw new APIError("FORBIDDEN", {
code: "FORBIDDEN",
message: "Access denied. This application is currently in maintenance mode.",
});
I'm using this in my auth.ts to handle my "maintenance" mode. To explain it simply, I am creating a maintenance mode that I can activate. If its activated, only certain users are allowed to log in or register. It is working, but the problem I'm having is with the APIError. I want to make it so that if this error occurs, it will take you to a custom error page instead of the /api/auth/callback/discord?code=... that it currently does. I am only using Discord auth with Postgres.
Solution:
You could add a mapProfileToUser in the discord provider config, then check the needed info to throw an APIError and redirect to a custom error page:
No description
Jump to solution
2 Replies
Solution
Ping
Ping2d ago
You could add a mapProfileToUser in the discord provider config, then check the needed info to throw an APIError and redirect to a custom error page:
No description
Erlandsson
ErlandssonOP2d ago
That worked! Thank you very much!

Did you find this page helpful?