-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions doesn't allow function name or route /api/admin #1781
Comments
This likely needs to stay blocked because you can change the base route to "/" and then you'd have "/admin" with you function named admin. We'd need a safer way to evaluate this. |
This doesn't give a warning if you have it in a regex constraint, it took me a while even to figure out that this was intentional. If I change it to say {
"bindings": [
{
"route": "{url:regex(admin)}"
}
]
} |
I'm having a problem here with getStatusQueryUris, eg I have a catch all proxy to route to SPA UI and have more specific proxies e.g /api/myFunc for actual backend stuff. Hitting the statusQueryUri will be routed to SPA UI, and I cannot make a proxy to force tit to the backend due to this issue. |
Workaround You can change the route name from Example: [FunctionName("ExampleAdminRoute")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v2/admin")]HttpRequest req, ILogger log)
{
//your function code
} Then, you can add a proxy to the route (more info on azure function proxies here). Proxies are stored in Make sure this file is copied to the build output directory i.e. including in .csproj file. Example {
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"AdminProxy": {
"matchCondition": {
"methods": [ "GET" ],
"route": "/api/admin"
},
"backendUri": "https://localhost/api/v2/admin"
}
}
} Now, when you run the functions app, you should see console output like: Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Listening on http://0.0.0.0:7071/
Hit CTRL-C to exit...
Http Functions:
AdminProxy: http://localhost:7071/api/admin
ExampleAdminRoute: http://localhost:7071/api/v2/admin Any requests coming to Proxies are flexible enough to match different types of requests (GET/POST) with parameters etc. The same applies to functions app written in any language i.e. Node.js, Python etc. More info in the stackoverflow question here. |
Do we plan to address this, or should we just document it? I have a related doc issue where the customer wants to name the function I understand blocking |
admin-* should be allowed to group admin apis! |
you could also change your function name from "notadmin" to "admin" and it would also break, but it shouldnt try to protect you from something you havent done yet. if the resolved routes arent in conflict when the app is built, it shouldnt cause an error. we got bit by this going the other way. originally, we had a routePrefix of |
shouldn't built-in routes have a prefix like /.admin or /_admin instead? SWA uses /_ah |
By default functions has a route prefix of "/api". When I try to create a function with the name "admin", Function gives an error saying
Error:
Function ($admin) Error: The specified route conflicts with one or more built in routes.
Session Id: 19b72d6133b2489987185f757f8c1fe2
Timestamp: 2017-08-11T18:18:36.311Z
Functions built in route uses /admin. Its understandable that this is reserved. However functions with route /api/admin or with any other route prefix should be allowed.
Infact it doesnt even allow function names like administrator or anything that starts with admin.
The text was updated successfully, but these errors were encountered: