Reputation: 315
I am writing an image processor proxy, similar to imageproxy, but using NestJS.
I want to declare an endpoint like this: GET /api/trim/http://your.image.url
where http://your.image.url
is the URL of the image that I want to transform.
In my controller, I would do something like this:
@Get('trim/:imageUrl')
async trimCanvas(
@Param('imageUrl') imageUrl: string,
): Promise<any> {
console.log(imageUrl);
return 'OK';
}
However, if I make a request, the controller is never hit and, instead, I get a default 404. Any ideas on how to make this work?
Upvotes: 2
Views: 2825
Reputation: 60357
By default, slashes will not be captured by the url param. You can append a regex in parentheses to your route param to change this behavior. Add a wildcard *
to your param, so that it also accepts /
:
@Get('trim/:imageUrl(*)')
Try it out in this codesandbox.
Upvotes: 5