Reputation: 418
Does the Azure Static web apps CLI(Github link) support other HTTP methods than GET and POST? I'm trying to set up Azure Static web apps CLI on my local environment, and GET and POST requests to port 4280 works fine, but PUT and DELETE requests fails with the error:
UnhandledPromiseRejectionWarning: SyntaxError: Invalid regular expression: /^*$/: Nothing to repeat.
For testing I'm calling the endpoints from Postman, and if I try directly on the Azure function (running on the default port 7071), these work as expected. Is there some configuration I need to add to ensure SWA CLI forwards my PUT and DELETE requests to the Azure Functions?
Sample function.json that works on port 7071, but not through 4280:
{ "bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["put"],
"route": "project/{id}"
},
{
"type": "http",
"direction": "out",
"name": "res"
} ] }
Upvotes: 0
Views: 287
Reputation: 418
Turns out the solution is adding a staticwebapp.config.json file (sample allowing any user to run PUT and DELETE calls, even when not authenticated):
{
"routes": [
{
"route": "/api/*",
"methods": ["GET", "POST", "PUT", "DELETE"]
}
]
}
Upvotes: 0