Skip to content

Commit

Permalink
Normalize double-slashed URLs coming from other core components. (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina authored Jul 17, 2024
1 parent e144cfa commit ec63e79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ if (config.hasProvider && dbconn) {
// Singleton instance across application
const oceanNode = OceanNode.getInstance(dbconn, node, provider, indexer, config)

function removeExtraSlashes(req: any, res: any, next: any) {
req.url = req.url.replace(/\/{2,}/g, '/')
next()
}

if (config.hasHttp) {
// allow up to 25Mb file upload
app.use(express.raw({ limit: '25mb' }))
Expand Down Expand Up @@ -153,7 +158,7 @@ if (config.hasHttp) {
})

// Integrate static file serving middleware

app.use(removeExtraSlashes)
app.use('/', httpRoutes)

app.listen(config.httpPort, () => {
Expand Down

0 comments on commit ec63e79

Please sign in to comment.