mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
don’t use cdn on dark
This commit is contained in:
parent
ad60268707
commit
6aca798a45
1 changed files with 13 additions and 9 deletions
|
@ -51,11 +51,7 @@ getFingerprint = (path) ->
|
|||
|
||||
logger.log "Finished generating file fingerprints"
|
||||
|
||||
|
||||
staticFilesBase = ""
|
||||
if Settings.cdn?.web?.host?
|
||||
staticFilesBase = Settings.cdn?.web?.host
|
||||
|
||||
cdnAvailable = Settings.cdn?.web?.host?
|
||||
|
||||
module.exports = (app, webRouter, apiRouter)->
|
||||
webRouter.use (req, res, next)->
|
||||
|
@ -63,11 +59,19 @@ module.exports = (app, webRouter, apiRouter)->
|
|||
next()
|
||||
|
||||
webRouter.use (req, res, next)->
|
||||
|
||||
isDark = req.headers?.host?.slice(0,4)?.toLowerCase() == "dark"
|
||||
isSmoke = req.headers?.host?.slice(0,5)?.toLowerCase() == "smoke"
|
||||
isLive = !isDark and !isSmoke
|
||||
|
||||
if cdnAvailable and isLive
|
||||
staticFilesBase = Settings.cdn?.web?.host
|
||||
else
|
||||
staticFilesBase = ""
|
||||
|
||||
res.locals.jsPath = jsPath
|
||||
res.locals.fullJsPath = Url.resolve(staticFilesBase, jsPath)
|
||||
|
||||
imgPath = "/img/"
|
||||
cssPath = "/stylesheets/"
|
||||
|
||||
res.locals.buildJsPath = (jsFile, opts = {})->
|
||||
path = Path.join(jsPath, jsFile)
|
||||
|
@ -89,11 +93,11 @@ module.exports = (app, webRouter, apiRouter)->
|
|||
|
||||
|
||||
res.locals.buildCssPath = (cssFile)->
|
||||
path = Path.join(cssPath, cssFile)
|
||||
path = Path.join("/stylesheets/", cssFile)
|
||||
return Url.resolve(staticFilesBase, path) + "?fingerprint=" + getFingerprint(path)
|
||||
|
||||
res.locals.buildImgPath = (imgFile)->
|
||||
path = Path.join(imgPath, imgFile)
|
||||
path = Path.join("/img/", imgFile)
|
||||
return Url.resolve(staticFilesBase, path)
|
||||
|
||||
next()
|
||||
|
|
Loading…
Reference in a new issue