Is there a way to setup API gateway to handle trai...
# help
k
Is there a way to setup API gateway to handle trailing
/
gracefully e.x
abc/hello/{123}
and
abc/hello/{123}/
should be both accepted and go to the same function
f
Hey @Kujtim Hoxha, does APIG consider them as two separate routes?
Are u using REST API or HTTP API?
k
So locally when I am developing one will give me a 404
f
I see. Are you able to add both routes? ie.
Copy code
route: {
  "GET abc/hello/{123}": "hello.main",
  "GET abc/hello/{123}/": "hello.main",
}
Do you know if this works?
k
I will try it out, I was hoping there is an automated way to do this 😂
f
Yeah let me know if it works for you.. we can look into automating this w/ SST
p
Did you get around to doing anything special here @Frank? I have a case with this:
"GET  /orders": "src/list-orders.handler",
"GET  /orders/{id}": "src/get-order.handler"
And of course, somebody will access /orders/. Do others just add extra routes? A bit tedious when we have many routes... 🙂
And also we'll get this error:
Error: A route path must always start with a "/" and not end with a "/"
f
Hey @PĂ„l Brattberg, there wasn’t anything we could do on the SST end.
I imagined this wouldn’t be a problem for most ppl b/c the API route is usually coded in ur own frontend, (not something user inputs), so you have full control over it, and can strip out the trailing
/
.
p
Thanks for reply @Frank! In this case, I'm building a public API and wanted to minimize confusion when other devs (or later me 😉) mess up. I'll look into detecting this in application code instead.