Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix when baseUrl and routeUrl is not the same #164

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ function run(config, listenOpts = {}) {
if (config) Queues.setConfig(config);
Queues.useCdn = typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;

app.locals.appBasePath = listenOpts.basePath || app.locals.appBasePath;

app.use(app.locals.appBasePath, express.static(path.join(__dirname, 'public')));
app.use(app.locals.appBasePath, routes);
if (listenOpts.disableListen) {
app.locals.appBasePath = listenOpts.basePath || app.locals.appBasePath;
app.use('/', express.static(path.join(__dirname, 'public')));
app.use('/', routes);
} else {
app.use(listenOpts.basePath || app.locals.appBasePath, express.static(path.join(__dirname, 'public')));
app.use(listenOpts.basePath || app.locals.appBasePath, routes);
}

const port = listenOpts.port || 4567;
const host= listenOpts.host || '0.0.0.0'; // Default: listen to all network interfaces.
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/dashboard/jobDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const util = require('util');
async function handler(req, res) {
const { queueName, queueHost, id } = req.params;
const { json } = req.query;
const basePath = req.baseUrl;
const basePath = req.app.locals.appBasePath + req.baseUrl;

const {Queues} = req.app.locals;
const queue = await Queues.get(queueName, queueHost);
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/dashboard/queueDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function handler(req, res) {
const {queueName, queueHost} = req.params;
const {Queues} = req.app.locals;
const queue = await Queues.get(queueName, queueHost);
const basePath = req.baseUrl;
const basePath = req.app.locals.appBasePath + req.baseUrl;
if (!queue) return res.status(404).render('dashboard/templates/queueNotFound', {basePath, queueName, queueHost});

let jobCounts;
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/dashboard/queueJobsByState.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function _html(req, res) {
const { queueName, queueHost, state } = req.params;
const {Queues} = req.app.locals;
const queue = await Queues.get(queueName, queueHost);
const basePath = req.baseUrl;
const basePath = req.app.locals.appBasePath + req.baseUrl;
if (!queue) return res.status(404).render('dashboard/templates/queueNotFound', {basePath, queueName, queueHost});

if (!isValidState(state, queue.IS_BEE)) return res.status(400).json({ message: `Invalid state requested: ${state}` });
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/dashboard/queueList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function handler(req, res) {
const {Queues} = req.app.locals;
const queues = Queues.list();
const basePath = req.baseUrl;
const basePath = req.app.locals.appBasePath + req.baseUrl;

return res.render('dashboard/templates/queueList', { basePath, queues });
}
Expand Down