fix: nop if we aren't in development

This commit is contained in:
Derrick Hammer 2023-11-01 23:38:32 -04:00
parent 4d591a6ad9
commit 8a88163f6f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 5 deletions

View File

@ -2,8 +2,14 @@ import type { APIRoute } from "astro";
import * as fs from "node:fs";
import * as path from "node:path";
export const GET: APIRoute = ({params, request}) => {
const filePath = path.resolve(process.cwd(), "dist/sw.js");
const fileContents = fs.readFileSync(filePath);
return new Response(fileContents, { status: 200, headers: { 'Content-Type': 'application/javascript' } });
}
export const GET: APIRoute = ({ params, request }) => {
if (process.env.MODE !== "development") {
return new Response();
}
const filePath = path.resolve(process.cwd(), "dist/sw.js");
const fileContents = fs.readFileSync(filePath);
return new Response(fileContents, {
status: 200,
headers: { "Content-Type": "application/javascript" },
});
};