-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
'@clerk/nextjs': minor | ||
--- | ||
|
||
Return 401 Response on protected API routes. This change introduces a new apiRoutes param on authMiddleware. | ||
If apiRoutes is omitted, then the following heuristic is used: | ||
- If the route path is ['/api/(.*)', '/trpc/(.*)'] | ||
- or Request has Content-Type: application/json | ||
- or Request method is not-GET,OPTIONS,HEAD, | ||
then this is considered an API route. | ||
|
||
After this commit, a 401 JSON Response is returned on the following 3 cases: | ||
- When the authenticateRequest function returns the Unknown state. | ||
- When the authenticateRequest function returns the Interstitial state and the route is an API route. | ||
- When the user is signed out, the route is protected (not public), and the route is an API route. (this one happens inside our default implementation of afterAuth. If it is overwritten, then the user needs to handle this case themselves) |