static-web-apps-cli
static-web-apps-cli copied to clipboard
Support for trailingSlash config
Is your feature request related to a problem? Please describe. staticwebappconfig.json will include a property to configure trailingSlash behavior:
The following normalization and redirect rules will apply for each of the available configurations:
Always
When setting trailingSlashes to always, all requests that don't include a trailing slash will be redirected to a trailing slash URL. For example, /contact will be redirected to /contact/.
"trailingSlash": "always"
| Requests to... | returns... | with the status... | and path... |
|---|---|---|---|
| /about | The /about/index.html file | 301 |
/about/ |
| /about/ | The /about/index.html file | 200 |
/about/ |
| /about/index.html | The /about/index.html file | 301 |
/about/ |
| /contact | The /contact.html file | 301 |
/contact/ |
| /contact/ | The /contact.html file | 200 |
/contact/ |
| /contact.html | The /contact.html file | 301 |
/contact/ |
Never
When setting trailingSlash to never, all requests ending in a trailing slash will be redirected to a non-trailing slash URL. For example, /contact/ will be redirected to /contact.
"trailingSlash": "never"
| Requests to... | returns... | with the status... | and path... |
|---|---|---|---|
| /about | The /about/index.html file | 200 |
/about |
| /about/ | The /about/index.html file | 301 |
/about |
| /about/index.html | The /about/index.html file | 301 |
/about |
| /contact | The /contact.html file | 200 |
/contact |
| /contact/ | The /contact.html file | 301 |
/contact |
| /contact.html | The /contact.html file | 301 |
/contact |
Auto
When setting trailingSlash to auto, all requests to folders will be redirected to a URL with a trailing slash. All requests to files will be redirected to a non-trailing slash URL.
"trailingSlash": "auto"
| Requests to... | returns... | with the status... | and path... |
|---|---|---|---|
| /about | The /about/index.html file | 301 |
/about/ |
| /about/ | The /about/index.html file | 200 |
/about/ |
| /about/index.html | The /about/index.html file | 301 |
/about/ |
| /contact | The /contact.html file | 200 |
/contact |
| /contact/ | The /contact.html file | 301 |
/contact |
| /contact.html | The /contact.html file | 301 |
/contact |
By default, when the trailingSlash configuration is omitted, Azure Static Web Apps will apply the following rules:
| Requests to... | returns... | with the status... | and path... |
|---|---|---|---|
| /about | The /about/index.html file | 200 |
/about |
| /about/ | The /about/index.html file | 200 |
/about/ |
| /about/index.html | The /about/index.html file | 200 |
/about/index.html |
| /contact | The /contact.html file | 200 |
/contact |
| /contact/ | The /contact.html file | 301 |
/contact |
| /contact.html | The /contact.html file | 200 |
/contact.html |
Describe the solution you'd like Static Web Apps CLI should apply the same redirect and normalization rules.
Hello @manekinekko . Can I take this issue ?
Hey @lcartel yes, please go ahead. Lmk if you need any help.
Any updates on your side @lcartel ? Let's know if you need help.
Hey @manekinekko. Sorry for the delay in the response. Here are the key elements blocking me right now:
- There is a tag status: need e2e tests - does it mean that the solution has been developed yet and just needs tests?
- I might need some precision regarding the roles of handlers, middlewares and routes-engine folders.
Thanks