Optional 308 redirect for /api pages #23953
Replies: 4 comments
-
IMHO I think there should be a way to deactivate the 308 in all situations, not only in I'm going to try to explain our case. Before this
We had implemented this in a similar way to: server.all('*', (req, res) => {
const redirectUrl = redirectToTrailingSlash(req)
if (redirectUrl) {
res.redirect(308, redirectUrl)
return
}
req.url = clearTrailingSlash(req)
handle(req, res)
}) However, now, with the new With this small change, it causes that pages like We reported this issue here #16586, but it was closed at once by @timneutkens, saying that it is the expected behavior. The reason is that we don't want a small degradation in SEO. A 308 redirect triggers a new crawl action to googlebot, and when you manage a large set of URLs, you want to avoid useless redirects. And setting Since @timneutkens closed the issue and it seems that it's something that will not be changed (although I think it should be reconsidered), I think like you @michaelcamdencommon, that there should be a mechanism to be able to deactivate these redirects. |
Beta Was this translation helpful? Give feedback.
-
@timneutkens any updates or future changes regarding this? |
Beta Was this translation helpful? Give feedback.
-
https://developers.google.com/search/docs/advanced/crawling/301-redirects |
Beta Was this translation helpful? Give feedback.
-
I also would like to add that at least in my case the point of redirecting to a path with trailing slash is to help browsers resolve relative paths, which is obviously not relevant for API calls. So yep, making /api redirects at least optional would be nice |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature request
Make
trailingSlashes
optional for /api pages.Is your feature request related to a problem? Please describe.
After updating to Next 9.5 and enabling trailing slashes my API calls started to report a 308 redirect header. This unfortunately broke some webhook integration because they weren't following the redirect.
Example:
/api/foo.js
used to serve/api/foo
, with trailingSlashes on/api/foo
returns a 308 redirect to/api/foo/
.A clear and concise description of what you want and what your use case is.
This isn't a huge issue for us since we just updated our various fetch calls, and integrations to use the trailing slashes, but it creates odd semantics around the API.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
N/A
Beta Was this translation helpful? Give feedback.
All reactions