mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
支持非根目录部署
This commit is contained in:
+2
-21
@@ -16,10 +16,12 @@ import { EnvModel } from '../data/env';
|
||||
import { errors } from 'celebrate';
|
||||
import path from 'path';
|
||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||
import { serveEnv } from '../config/serverEnv';
|
||||
|
||||
export default ({ app }: { app: Application }) => {
|
||||
app.enable('trust proxy');
|
||||
app.use(cors());
|
||||
app.get(`${config.api.prefix}/env.js`, serveEnv);
|
||||
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
|
||||
|
||||
app.use(
|
||||
@@ -31,27 +33,6 @@ export default ({ app }: { app: Application }) => {
|
||||
}),
|
||||
);
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (req.path.startsWith('/api') || req.path.startsWith('/open')) {
|
||||
next();
|
||||
} else {
|
||||
return handler(req, res, {
|
||||
public: path.join(config.rootPath, 'static/dist'),
|
||||
rewrites: [{ source: '**', destination: '/index.html' }],
|
||||
headers: [
|
||||
{
|
||||
source: 'index.html',
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'no-cache',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
});
|
||||
app.use(bodyParser.json({ limit: '50mb' }));
|
||||
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user