Skip to content

Commit

Permalink
feat(auth0): automatically give origin to api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
aiji42 committed Nov 9, 2021
1 parent fa59f94 commit eca7ae6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/auth0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const verifyAuth0Session = async (
req: NextRequest,
apiEndpoint: string
): Promise<boolean> => {
const res = await fetch(apiEndpoint, {
headers: { cookie: req.headers.get('cookie') ?? '' }
})
const res = await fetch(
(/^\//.test(apiEndpoint) ? req.nextUrl.origin : '') + apiEndpoint,
{
headers: { cookie: req.headers.get('cookie') ?? '' }
}
)

return res.ok
}

0 comments on commit eca7ae6

Please sign in to comment.