WIP work on getting nextauth + graphql working

This commit is contained in:
Abel Luck 2023-06-06 11:46:35 +00:00
parent 45f8cb1234
commit 24d52eef3d
8 changed files with 668 additions and 21 deletions

View file

@ -50,10 +50,11 @@ const build = async (config: IAppConfig): Promise<Glue.Manifest> => {
route: {
path: "/graphql",
options: {
auth: {
strategies: ["nextauth-jwt"],
mode: "optional",
},
auth: false,
// auth: {
// strategies: ["nextauth-jwt"],
// mode: "optional",
// },
},
},
pgConfig: config.postgraphile.authConnection,

View file

@ -19,7 +19,7 @@
"graphile-migrate": "^1.4.1",
"graphile-worker": "^0.13.0",
"node-jose": "^2.2.0",
"postgraphile": "4.13.0",
"postgraphile": "4.12.3",
"graphql": "16.6.0"
},
"devDependencies": {

View file

@ -8,8 +8,5 @@ export const metamigoDataProvider = async (client: any) => {
{},
{ introspection: { schema: schema.data.__schema } }
);
const dataProvider = async (type: any, resource: any, params: any) => graphqlDataProvider(type, resource, params);
return dataProvider;
return graphqlDataProvider;
};

View file

@ -61,14 +61,11 @@ const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
return {
secret: nextAuth.secret,
session: {
jwt: true,
strategy: "database",
maxAge: 8 * 60 * 60, // 8 hours
},
jwt: {
secret: nextAuth.secret,
encryption: false,
signingKey: nextAuth.signingKey,
encryptionKey: nextAuth.encryptionKey,
},
providers,
adapter,

View file

@ -4,7 +4,7 @@ export default createProxyMiddleware({
target:
process.env.NODE_ENV === "production"
? "http://metamigo-api:3001"
: "http://localhost:3001",
: "http://127.0.0.1:3001",
changeOrigin: true,
pathRewrite: { "^/graphql": "/graphql" },
xfwd: true,
@ -20,8 +20,6 @@ export default createProxyMiddleware({
let token = req.cookies["__Secure-next-auth.session-token"];
if (!token) token = req.cookies["next-auth.session-token"];
// console.log(req.body);
// if (req.body.query) console.log(req.body.query);
if (token) {
proxyReq.setHeader("authorization", `Bearer ${token}`);
proxyReq.removeHeader("cookie");