Skip to content

Commit

Permalink
fix: set config.api.externalResolver to true in order to avoid weird … (
Browse files Browse the repository at this point in the history
#336)

* fix: set config.api.externalResolver to true in order to avoid weird behavior (getsentry/sentry-javascript#3852 (comment))

* Update packages/web/app/src/lib/api/extract-access-token-from-request.ts
  • Loading branch information
n1ru4l authored Sep 6, 2022
1 parent 6540155 commit f4e92b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/web/app/pages/api/join-waiting-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ async function joinWaitingList(req: NextApiRequest, res: NextApiResponse) {
}

export default withSentry(joinWaitingList);

export const config = {
api: {
externalResolver: true,
},
};
4 changes: 2 additions & 2 deletions packages/web/app/pages/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ async function graphql(req: NextApiRequest, res: NextApiResponse) {
accessSpan.setHttpStatus(401);
accessSpan.finish();
finishTransaction();

res.status(401).send({});
res.status(401).json({});
return;
}

Expand Down Expand Up @@ -141,5 +140,6 @@ export const config = {
bodyParser: {
sizeLimit: '6mb',
},
externalResolver: true,
},
};
13 changes: 10 additions & 3 deletions packages/web/app/src/lib/api/extract-access-token-from-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import { backendConfig } from '@/config/backend-config';
supertokens.init(backendConfig());

export async function extractAccessTokenFromRequest(req: NextApiRequest, res: NextApiResponse): Promise<string> {
await superTokensNextWrapper(async next => await verifySession()(req as any, res as any, next), req, res);
// TODO: figure out what kind of error this can raise :)
const accessToken = (req as any).session.getAccessToken();
await superTokensNextWrapper(
async next =>
await verifySession({
sessionRequired: false,
})(req as any, res as any, next),
req,
res
);
// Session can be undefined in case no access token was sent.
const accessToken = (req as any).session?.getAccessToken() || null;
return accessToken;
}

0 comments on commit f4e92b2

Please sign in to comment.