Azure / Azure/static-web-apps-cli

Local web app dev routes with generic char defined in staticwebapp.config.json are not treated as generic

Abierto
#580 4 comentarios 0 reacciones 1 asignado Reclamado por @sgollapudi77 Ver en GitHub
priority: medium (P1) scope: msha scope: rules engine type: bug
Lenguaje dominante
TypeScript
Estrellas
668
Forks
156
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Are you accessing the CLI from the default port `:4280` ?**

- [x] No, I am using a different port number (`--port`) and accessing the CLI from that port
- [ ] Yes, I am accessing the CLI from port `:4280`

**Describe the bug**
When I define a route with /AAA* , /AAA* is proxied to the defined rewrite but /AAATEST is proxied to the frontend app

**To Reproduce**
`npx @azure/static-web-apps-cli start https://localhost:5173 --swa-config-location ./ -s -e localhost.internal.tld.pem -k localhost.internal.tld.key -p 8788 --api-location ./api -t 120 --run 'npm run dev'`

staticwebapp.config.json
```json
{
"globalHeaders": {
"content-security-policy": "default-src https: 'unsafe-eval' 'unsafe-inline'; object-src 'none'"
},
"routes": [
{
"route": "/GOOGLE",
"redirect": "https://www.google.fr",
"statusCode": 302
},
{
"route": "/!TEST",
"rewrite": "/api/redirect"
},
{
"route": "/AAA*",
"rewrite": "/api/redirect"
}
]
}
```
**Expected behavior**
browsing to https://localhost.internal.tld:8788/AAATEST must be rewritten to /api/redirect as explained in the documentation https://learn.microsoft.com/fr-fr/azure/static-web-apps/configuration#wildcards

**Bugged behavior**
browsing to https://localhost.internal.tld:8788/AAATEST
`[swa] GET https://localhost:5173/AAATEST (proxy)`

browsing to https://localhost.internal.tld:8788/AAA*
```
[swa] GET http://localhost:7071/api/redirect (proxy)
[api] [2022-10-05T05:53:41.729Z] Executing HTTP request: {
[api] [2022-10-05T05:53:41.729Z] requestId: "f6ed30b0-5580-4395-89f7-e34bd1e7e2ad",
[api] [2022-10-05T05:53:41.729Z] method: "GET",
[api] [2022-10-05T05:53:41.729Z] userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
[api] [2022-10-05T05:53:41.729Z] uri: "/api/redirect"
[api] [2022-10-05T05:53:41.729Z] }
[api] [2022-10-05T05:53:41.730Z] Executing 'Functions.redirect' (Reason='This function was programmatically called via the host APIs.', Id=c3549609-e9a1-483c-9f0d-81593625eb5a)
[api] [2022-10-05T05:53:41.732Z] to:AA*
[api] [2022-10-05T05:53:41.735Z] Received FunctionInvocationRequest
[api] [2022-10-05T05:53:41.899Z] Executed 'Functions.redirect' (Succeeded, Id=c3549609-e9a1-483c-9f0d-81593625eb5a, Duration=169ms)
[api] [2022-10-05T05:53:41.901Z] Executed HTTP request: {
[api] [2022-10-05T05:53:41.901Z] requestId: "f6ed30b0-5580-4395-89f7-e34bd1e7e2ad",
[api] [2022-10-05T05:53:41.901Z] identities: "",
[api] [2022-10-05T05:53:41.901Z] status: "500",
[api] [2022-10-05T05:53:41.901Z] duration: "172"
[api] [2022-10-05T05:53:41.901Z] }
[swa] GET https://localhost.lesmuids.windows:8788/api/redirect - 500
```
500 status is my normal behavior (the function return status 500 because AAA* is not allowed)

**Desktop (please complete the following information):**

- OS: MacOS
- Version 10.15.7

**Additional context**
```
swa -version
Welcome to Azure Static Web Apps CLI (1.0.2)
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.