mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 15:56:00 +00:00
#228 running dbgate on subpath
This commit is contained in:
10
packages/api/src/utility/getExpressPath.js
Normal file
10
packages/api/src/utility/getExpressPath.js
Normal file
@@ -0,0 +1,10 @@
|
||||
function getExpressPath(path) {
|
||||
path = path.replace(/\/*$/, '').replace(/^\/*/, '');
|
||||
const root = (process.env.WEB_ROOT || '').replace(/^\/*/, '').replace(/\/*$/, '');
|
||||
if (root) {
|
||||
return `/${root}/${path}`;
|
||||
}
|
||||
return `/${path}`;
|
||||
}
|
||||
|
||||
module.exports = getExpressPath;
|
||||
@@ -1,5 +1,6 @@
|
||||
const _ = require('lodash');
|
||||
const express = require('express');
|
||||
const getExpressPath = require('./getExpressPath');
|
||||
|
||||
/**
|
||||
* @param {string} route
|
||||
@@ -74,6 +75,6 @@ module.exports = function useController(app, electron, route, controller) {
|
||||
}
|
||||
|
||||
if (app) {
|
||||
app.use(route, router);
|
||||
app.use(getExpressPath(route), router);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user