Azure / Azure/static-web-apps-cli

swa emulator ignoring staticwebapp.config.json routes

Offen
#630 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
status: investigating
Vorherrschende Sprache
TypeScript
Sterne
668
Forks
156
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

SWA_CLI_VERSION: 1.0.4

**Are you accessing the CLI from the default port `:4280` ?**
- [X] Yes, I am accessing the CLI from port `:4280`

**Describe the bug**
I have a very simple staticwebapp.config.json with one secured route that _should_ redirect but does not.

```
{
"$schema": "https://json.schemastore.org/staticwebapp.config.json",
"routes": [
{
"route": "/example",
"allowedRoles": ["rolethatdoesntexist"]
}
],
"responseOverrides": {
"401": {
"redirect": "/.auth/login/twitter",
"statusCode": 302
}
},
"navigationFallback": {
"rewrite": "index.html",
"exclude": [
"/images/*.{png,jpg,gif}",
"/css/*"
]
}
}
```

I've tried a million variations of the route, even tried to add a `/*` route to redirect all URLs, but no routes appear to work. This staticwebapp.config.json works when deployed to Azure, just not when using the emulator, making it hard to develop.

When using silly verbose mode, this is printed when handling the route:

```
[swa] --------------------------------------------------------
[swa] ------------------- processing route -------------------
[swa] --------------------------------------------------------
[swa] processing /example
[swa] checking for matching route
[swa] checking auth request
[swa] - not an auth request
[swa] checking function request
[swa] - not a function request
[swa] checking HTTP method: GET
[swa] - method is valid (allow-list: GET,HEAD,OPTIONS)
[swa] checking for query params
[swa] checking rewrite auth login request
[swa] checking rewrite auth logout request
[swa] checking authorizations for route
[swa] - no matching rule
[swa] - access authorized
[swa] using userConfig
[swa] - userConfig:
[swa] checking storage content
[swa] remote dev server detected.
[swa] - url: /example
[swa] - target: http://localhost:5173
[swa] customUrl: false
[swa] is4xx: false
[swa] remote dev server detected. Proxying request
[swa] - url: /example
[swa] - code: 200
[swa] GET http://localhost:5173/example (proxy)
[swa] getting response from dev server
[swa] GET http://localhost:4280/example - 304
```

**Expected behavior**
I expect the URL `http://localhost:4280/example` to route to authentication. (Or at least the mocked authentication)

**Screenshots**

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

- OS: Windows 10
- Version: 19044

**Additional context**
This may be related -- but as far as I can tell from other issue threads, it can be ignored?

```
[swa] Loading staticwebapp.config.json schema...
[swa] Failed to load schema from https://json.schemastore.org/staticwebapp.config.json
[swa] WARNING: Failed to load staticwebapp.config.json schema. Continuing without validation!
```

If I move the staticwebapp.config.json from the directory, it shows a different error that it can't find it, so I at least know it's finding the file where it is.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Führen Sie den Emulator auf Port 4280 mit der bereitgestellten staticwebapp.config.json aus und aktivieren Sie die ausführliche Protokollierung. Beginnen Sie mit der Ausgabe der Routenverarbeitung für /example, insbesondere mit den Prüfungen von authorization und userConfig, und verifizieren Sie anschließend, dass die konfigurierten allowedRoles und 401 responseOverride angewendet werden, bevor das Proxying erfolgt. Als abgeschlossen gilt die Aufgabe, wenn /example die erwartete Mock-Authentifizierungsweiterleitung erreicht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, typescript
Bereich
authentication, cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.