fix: nop if we aren't in development
This commit is contained in:
parent
4d591a6ad9
commit
8a88163f6f
|
@ -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" },
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue