diff --git a/client/pages/_app.tsx b/client/pages/_app.tsx index 0c887e17..5d46b912 100644 --- a/client/pages/_app.tsx +++ b/client/pages/_app.tsx @@ -31,7 +31,7 @@ function MyApp({ Component, pageProps }: AppProps) { Drift - + diff --git a/client/pages/api/markdown/[id].ts b/client/pages/api/markdown/[id].ts index cfb734f0..3cf942a9 100644 --- a/client/pages/api/markdown/[id].ts +++ b/client/pages/api/markdown/[id].ts @@ -11,6 +11,10 @@ const renderMarkdown: NextApiHandler = async (req, res) => { Authorization: `Bearer ${req.cookies["drift-token"]}` } }) + console.log(file.status) + if (file.status !== 200) { + return res.status(404).json({ error: "File not found" }) + } const json = await file.json() const { content, title } = json diff --git a/client/pages/api/raw/[id].ts b/client/pages/api/raw/[id].ts index d07eb525..7325c2b6 100644 --- a/client/pages/api/raw/[id].ts +++ b/client/pages/api/raw/[id].ts @@ -9,10 +9,12 @@ const getRawFile = async (req: NextApiRequest, res: NextApiResponse) => { Authorization: `Bearer ${req.cookies["drift-token"]}` } }) - const json = await file.json() + res.setHeader("Content-Type", "text/plain; charset=utf-8") res.setHeader("Cache-Control", "s-maxage=86400") if (file.ok) { + const json = await file.json() + console.log(json) const data = json const { title, content } = data // serve the file raw as plain text diff --git a/client/styles/markdown.css b/client/styles/markdown.css index df9ecd85..cf6386f9 100644 --- a/client/styles/markdown.css +++ b/client/styles/markdown.css @@ -16,8 +16,8 @@ article img { article [id]::before { content: ""; display: block; - height: 70px; - margin-top: -70px; + height: var(--gap-half); + margin-top: calc(var(--gap-half) * -1); visibility: hidden; } diff --git a/server/src/routes/files.ts b/server/src/routes/files.ts index 50ffc55b..21ee2b71 100644 --- a/server/src/routes/files.ts +++ b/server/src/routes/files.ts @@ -13,6 +13,11 @@ files.get("/raw/:id", secretKey, async (req, res, next) => { attributes: ["title", "content"], }) + + if (!file) { + return res.status(404).json({ error: "File not found" }) + } + // TODO: JWT-checkraw files if (file?.post?.visibility === "private") { // jwt(req as UserJwtRequest, res, () => {