From: Justin Wind Date: Sat, 19 Apr 2025 20:05:21 +0000 (-0700) Subject: fix static route ordering X-Git-Url: http://git.squeep.com/?a=commitdiff_plain;h=8fca67d6d0fffb119a9491174a6866c90f0df168;p=squeep-api-dingus fix static route ordering --- diff --git a/lib/dingus.js b/lib/dingus.js index 08ebe86..9ee9cf8 100644 --- a/lib/dingus.js +++ b/lib/dingus.js @@ -120,15 +120,16 @@ class Dingus { throw new RangeError('staticRoute parameter should not have trailing slash'); } + // /static/ serves /static/index.html + // define before /static/:file else :file would match '' + this.on(['GET'], `${opt.staticRoute}/`, this.handlerGetStaticFile.bind(this), 'index.html'); + // /static/:file serves file this.on(['GET'], `${opt.staticRoute}/:file`, opt.staticRouteFileName, this.handlerGetStaticFile.bind(this)); // /static forwards to /static/ this.on(['GET'], opt.staticRoute, this.handlerRedirect.bind(this), `${this.proxyPrefix}${opt.staticRoute}/`); - // /static/ serves /static/index.html - this.on(['GET'], `${opt.staticRoute}/`, this.handlerGetStaticFile.bind(this), 'index.html'); - // /favicon.ico and /robots.txt serve from /static/ this.on(['GET'], '/favicon.ico', this.handlerGetStaticFile.bind(this), 'favicon.ico'); this.on(['GET'], '/robots.txt', this.handlerGetStaticFile.bind(this), 'robots.txt');