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