mirror of
https://github.com/graphql-hive/console
synced 2026-04-30 10:57:17 +00:00
* add supertoken container to docker-compose file * yeah I am sorry this one big commit and I am ashamed of it * use logOut function * feat: show header on 404 page * feat: better handling for organization cookie when not authenticated * wrap it * check session within server side props * add is_admin flag user migration * simplify and annotate the config * fix: handle status codes + fix email/password sign up with import from auth0 * no hardcoded env pls * decode process.env * secure update user id mapping via a key * fix: login form * lol we don't need to hit the API * fix: do graphql api authorization via authorization header instead of cookie * implement isAdmin flag * fix: types :) * skipit * yo we can run this * set env variables * disable because it annoys the hell out of me * use the right host * add not about token length * refactor: decode environment variables * feat: store external user id from guthub/google provider in the database * workaround supertokens omitting null values from the token * re-enable check * i have no time for this shit * add missing env variable * fix: email test; missing domain extension * configure pulumi deployment Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> Co-authored-by: Dotan Simha <dotansimha@gmail.com> * configure pulumi deployment Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> Co-authored-by: Dotan Simha <dotansimha@gmail.com> * configure pulumi deployment Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> Co-authored-by: Dotan Simha <dotansimha@gmail.com> * configure pulumi deployment Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> * fix: env names * fix: link google account to the correct db record * feat: email confirmation emails * ? * bump ts-node * fix types * omit package form the bundle * remove it from dependencies... * add emails apckage to dev deps * resolve eslint issues * remove comments * update dev info + change env variable (no need to expose it on the frontend) * use correct user id lol Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> Co-authored-by: Dotan Simha <dotansimha@gmail.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { superTokensNextWrapper } from 'supertokens-node/nextjs';
|
|
import { middleware } from 'supertokens-node/framework/express';
|
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
import { Request, Response } from 'express';
|
|
import supertokens from 'supertokens-node';
|
|
import { backendConfig } from '@/config/backend-config';
|
|
import NextCors from 'nextjs-cors';
|
|
|
|
supertokens.init(backendConfig());
|
|
|
|
/**
|
|
* Route for proxying to the underlying SuperTokens backend.
|
|
*/
|
|
export default async function superTokens(req: NextApiRequest & Request, res: NextApiResponse & Response) {
|
|
// NOTE: We need CORS only if we are querying the APIs from a different origin
|
|
await NextCors(req, res, {
|
|
methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
|
|
origin: process.env['NEXT_PUBLIC_APP_BASE_URL'],
|
|
credentials: true,
|
|
allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
|
|
});
|
|
|
|
await superTokensNextWrapper(
|
|
async next => {
|
|
await middleware()(req, res, next);
|
|
},
|
|
req,
|
|
res
|
|
);
|
|
|
|
if (!res.writableEnded) {
|
|
res.status(404).send('Not found');
|
|
}
|
|
}
|