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

@@ -2,21 +2,20 @@
import { CGGService } from 'cgg/Application.ts';
import { Router, send } from 'oak';
const app = new CGGService({ prefix: '/' });
const prefix = ''
const app = new CGGService({ prefix: `/${prefix}` });
// app.route(new Router()
// .get('/', ctx => ctx.response.body = 'warstone-web service')
// );
const ROOT_DIR = "./public/testdata", ROOT_DIR_PATH = "/public";
const ROOT_DIR = "./project-warstone/dist";
app.use(async (ctx, next) => {
if (!ctx.request.url.pathname.startsWith(ROOT_DIR_PATH)) {
next();
return;
}
const filePath = ctx.request.url.pathname.replace(ROOT_DIR_PATH, "");
app.use(async (ctx) => {
if (ctx.request.url.pathname.includes('favicon')) return ctx.response.status = 404;
const filePath = ctx.request.url.pathname.replace(prefix, "");
await send(ctx, filePath, {
root: ROOT_DIR,
index: 'index.html'
});
});