Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion @app/lib/src/withApollo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function makeServerSideLink(req: any, res: any) {
return new GraphileApolloLink({
req,
res,
pgl: req.app.get("pgl"),
pgl: req.pgl,
});
}

Expand Down
9 changes: 8 additions & 1 deletion @app/server/src/middleware/installSSR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { GraphileApp } from "@app/lib" with {
import { type Express } from "express";
import { createServer } from "http";
import next from "next";
import { type PostGraphileInstance } from "postgraphile";

import { getUpgradeHandlers } from "../app";

Expand Down Expand Up @@ -38,14 +39,20 @@ export default async function installSSR(app: Express) {
console.error(e);
process.exit(1);
});

const pgl = app.get("pgl") as PostGraphileInstance;

app.get("*", async (req, res) => {
const handler = await handlerPromise;
const graphileApp: GraphileApp = {
CSRF_TOKEN: req.csrfToken(),
ROOT_URL: process.env.ROOT_URL || "http://localhost:5678",
...(process.env.T_AND_C_URL && { T_AND_C_URL: process.env.T_AND_C_URL }),
};

(req as any).graphileApp = graphileApp;
(req as any).pgl = pgl;

const handler = await handlerPromise;
handler(req, res);
});

Expand Down
Loading