Loopback-next: Case insensitive routing

Created on 13 Feb 2020  路  2Comments  路  Source: strongloop/loopback-next

While porting a legacy API to LoopBack 4 I've noticed that LoopBack routing is case sensitive.
Is there a way to make it case insensitive so that it doesn't throw 404 errors if route casing is different (/api/userprofile or /api/userProfile)?

Case-insensitive routing is default in Express.js. I was expecting LB4 to behave the same way.

REST question

Most helpful comment

@dkrantsberg AFAIK, lb4 only uses Express.js for its middlewares, and uses its own routing engine. (see Circling back to Express with a twist).

lb4 does have the concept of Sequences (where the REST router is invoked), to which you can "normalize" the incoming route path before passing it into the router's findRoute()by extending and modifying DefaultSequence (see Invoke Operations using Routes) .

You can also completely replace the REST router for more flexibility (see Customize the REST router).

All 2 comments

@dkrantsberg AFAIK, lb4 only uses Express.js for its middlewares, and uses its own routing engine. (see Circling back to Express with a twist).

lb4 does have the concept of Sequences (where the REST router is invoked), to which you can "normalize" the incoming route path before passing it into the router's findRoute()by extending and modifying DefaultSequence (see Invoke Operations using Routes) .

You can also completely replace the REST router for more flexibility (see Customize the REST router).

Yes, this is what I ended up doing. Thanks, @achrinza.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shadyanwar picture shadyanwar  路  3Comments

teambitcodeGIT picture teambitcodeGIT  路  3Comments

mightytyphoon picture mightytyphoon  路  3Comments

joeytwiddle picture joeytwiddle  路  3Comments

aceraizel picture aceraizel  路  3Comments