Azure / Azure/static-web-apps

the way dynamic routes works stopped working the way it used to

Open
#1,230 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

On my static nuxt project I have the following routes:

`/request/new`
`/request/appointment`
`/request/{id}`
`/request`

Since ~2 weeks ago only /requests works on SWA after deploying. `/new`, `/appointment` and `/{id}` both redirect back to /request

Now when I configure a wildcard on `/request/*` and add both` /request/new` and `/request/appointment` to my staticwebapp.config.js it wont let me deploy it. However this always used to work with just a wildcard on /request

**To Reproduce**
Steps to reproduce the behavior:

Old staticwebapp.config (this always used to work fine)
```json
{
"trailingSlash": "never",
"globalHeaders": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, OPTIONS, POST, PUT"
},
"routes": [
{
"route": "/request/*",
"rewrite": "/index.html"
},
{
"route": "/kennisbank/*",
"rewrite": "/index.html"
},
{
"route": "/user/*",
"rewrite": "/index.html"
}
],
"responseOverrides": {
"400": {
"rewrite": "/404.html"
},
"401": {
"statusCode": 302,
"redirect": "/404.html"
},
"403": {
"rewrite": "/404.html"
},
"404": {
"rewrite": "/404.html"
}
}
}
```

new one that still does not work but the one I currently use:
```json
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/*.{png,jpg,jpeg,gif,bmp,bin,ico,js,css}"]
},
"routes": [
{
"route": "/request/*",
"rewrite": "/request/index.html"
},
{
"route": "/kennisbank/id/*",
"rewrite": "/kennisbank/index.html"
}
],
"responseOverrides": {
"400": {
"rewrite": "/404.html"
},
"401": {
"statusCode": 302,
"redirect": "/404.html"
},
"403": {
"rewrite": "/404.html"
},
"404": {
"rewrite": "/404.html"
}
}
}
```

**Expected behavior**
I expect all dynamic routes to not redirect back to their parent route.

**Device info (if applicable):**
- OS: W11
- Browser Chrome
- Version 115.0.5790.102

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.