Skip to content

Commit

Permalink
fix: add mapping .br extension to the same path without it (#32)
Browse files Browse the repository at this point in the history
* fix: add mapping .br extension to the same path without it

* typing
  • Loading branch information
leanmendoza authored Oct 5, 2021
1 parent f62c019 commit a9c44f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/decentraland-ecs/src/setupProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ const setupProxy = (dcl: any, app: express.Application) => {
}

createStaticRoutes(app, '/images/decentraland-connect/*', dclKernelImagesDecentralandConnect)
createStaticRoutes(app, '/@/artifacts/unity-renderer/*', dclUnityRenderer)
createStaticRoutes(app, '/@/artifacts/unity-renderer/*', dclUnityRenderer, (filePath) =>
filePath.replace(/.br+$/, '')
)
createStaticRoutes(app, '/@/artifacts/loader/*', dclKernelLoaderPath)
createStaticRoutes(app, '/default-profile/*', dclKernelDefaultProfilePath)
}

const createStaticRoutes = (app: express.Application, route: string, localFolder: string) => {
const createStaticRoutes = (
app: express.Application,
route: string,
localFolder: string,
mapFile?: ((filePath: string) => string)
) => {
app.use(route, (req, res, next) => {
const options = {
root: localFolder,
Expand All @@ -82,7 +89,7 @@ const createStaticRoutes = (app: express.Application, route: string, localFolder
}
}

const fileName = req.params[0]
const fileName: string = mapFile ? mapFile(req.params[0]) : req.params[0]

res.sendFile(fileName, options, (err) => {
if (err) {
Expand Down

0 comments on commit a9c44f7

Please sign in to comment.