From 084c509fad0fdf2415587e0e3af8e86fd306447a Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 29 Jan 2020 02:39:04 +0100 Subject: viewer: fix for the developper server when URLs with parameters are used (timestamps) --- viewer/vue.config.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'viewer/vue.config.js') diff --git a/viewer/vue.config.js b/viewer/vue.config.js index 614f975..55cd2e7 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js @@ -33,8 +33,11 @@ module.exports = { before: (app, server, compiler) => { app.get(`${process.env.VUE_APP_DATA_URL}*`, (req, res) => { const fs = require("fs"); - const fileName = `${process.env.VUE_APP_EXAMPLE_PROJECT}${req.url.slice(process.env.VUE_APP_DATA_URL.length)}`; - const file = fs.readFileSync(decodeURIComponent(fileName)); + const url = req.url.slice(process.env.VUE_APP_DATA_URL.length); + const paramIdx = url.indexOf('?'); + const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx); + const fullpath = `${process.env.VUE_APP_EXAMPLE_PROJECT}${decodeURIComponent(filepath)}`; + const file = fs.readFileSync(fullpath); res.end(file); }); } -- cgit v1.2.3