Fixes dev server issues, adds frontend proxy
This commit is contained in:
@@ -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());
|
||||
|
||||
|
Reference in New Issue
Block a user