No way to reject a route
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 933
- Avg merge
- 12d 18h
- Merged PRs (30d)
- 2
Description
### Describe the bug
Let's say I want to have an SPA served from https://example.com, and its APIs from https://example.com/api/name-of-api.
I would imagine setting up the two routes like this:
```json
[
{
"RouteId": "app",
"Match": {
"Path": "/{**any}"
},
"ClusterId": "app"
},
{
"RouteId": "first-api",
"Match": {
"Path": "/api/first-api/{*any}"
},
"ClusterId": "first-api"
},
{
"RouteId": "second-api",
"Match": {
"Path": "/api/second-api/{*any}"
},
"ClusterId": "second-api"
}
]
```
All three of these URLs will work as intended:
https://example.com/
https://example.com/api/first-api
https://example.com/api/second-api
But this URL will also be accepted, and quietly return the same as https://example.com
https://example.com/api/third-and-totally-invalid-api
Ideally, I would want to instruct the proxy to reject that route with a 404, perhaps with something like this:
```typescript
{
"RouteId": "invalid-api",
"Match": {
"Path": "/api/{*any}"
},
StatusCode: 404
},
```
### To Reproduce
Listed in the description
### Further technical details
Yarp.ReverseProxy 1.1.1
On Windows 10, .NET 6
Contributor guide
Assessment
This issue has not been assessed yet.