Azure / Azure/static-web-apps

trailingSlash:never does not redirect to the nontrailing slash url

Open
#1,624 0 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**

In my staticwebapp.config.json, "trailingSlash":"never" is specified but any URL ending with a trailing slash is not getting redirected to a nontrailing slash URL. For example, /contact/ remains /contact/ and does not get redirected to /contact. This is causing a problem with my site SEO as the two urls (/contact/ and /contact) are seen as separate pages.

The config is placed in the root directory of the application. All other settings in the staticwebapp.config.json are correctly applied to the application (i.e. Content-Security-Policy).

**To Reproduce**
Steps to reproduce the behavior:
1. Add {"trailingSlash":"never"} to staticwebapp.config.json
2. Deploy staticwebapp.config.json to a development or production server using the VS Code Github workflow.
3. Enter a url with trailing slash into the browser. (i.e. /contact/)

**Expected behavior**
The browser should redirect with 301 status to the url without the trailing slash. For example, /contact/ should redirect to /contact. This behavior is documented here:
https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#trailing-slash

**Additional context**
My application is built with Vite/React

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.