Fixes dev server issues, adds frontend proxy

This commit is contained in:
Emma
2023-06-11 14:15:44 -06:00
parent b951d1970d
commit 8fb7494464
6 changed files with 30 additions and 12 deletions

View File

@@ -1,7 +1,6 @@
import { proxy } from "https://deno.land/x/oak_http_proxy@2.1.0/mod.ts";
import { fileExists } from "./lib/fileExists.ts";
import { Application, Context, Router } from "oak";
import { path } from "https://deno.land/x/compress@v0.4.1/deps.ts";
const app = new Application();
@@ -21,6 +20,7 @@ for await (const dirEntry of Deno.readDir(Deno.cwd())) {
args: [
'run',
...perms,
'--watch',
filename,
port
]
@@ -28,8 +28,8 @@ for await (const dirEntry of Deno.readDir(Deno.cwd())) {
const prefix = Deno.readTextFileSync(prefixfile);
const routes = new Router()
.all(`/${prefix}/(.*)`, proxy((ctx: Context) => `http://localhost:${port}${ctx.request.url.pathname}`, {}))
.all(prefix ? `/${prefix}/(.*)` : '/(.*)', proxy((ctx: Context) => `http://localhost:${port}${ctx.request.url.pathname}`))
app.use(routes.allowedMethods());
app.use(routes.routes());