Handle redirects
See original GitHub issueThere are some situations were redirects are encouraged, specifically:
If two URIs differ only in the trailing slash, and the server has associated a resource with one of them, then the other URI MUST NOT correspond to another resource. Instead, the server MAY respond to requests for the latter URI with a 301 redirect to the former.
We could do this by throwing errors with 3xx status codes, but since these are not actual errors this is sort of wrong. On the other hand, this might be requested by functions that don’t actually return anything (e.g., setRepresentation
), so they have no real way of returning anything in another way.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to Handle Redirects - Nest Developers
The REST client detects the redirect and requests the page that the client was redirected to. Some HTTP implementations do not forward the...
Read more >Redirections in HTTP - MDN Web Docs - Mozilla
URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, or...
Read more >Handle redirects with Bulk Redirects · Cloudflare Pages docs
In this tutorial, you will learn how to use Bulk Redirects (beta) to handle redirects that surpasses the 1,100 redirect rules limit set...
Read more >The Ultimate Guide to Redirects: URL Redirections Explained
Redirects send users & search engines from one URL to another. Find out how to use each type here.
Read more >Managing URL redirects - Information Technology Services
URL redirection is a technique for making a web page available under more than one URL address. When a web browser attempts to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This comment pertains specifically to
Assuming we probably do want to do the redirect.
If we don’t want to change the interface of
ResourceStore
, I can only see a few possible ways to go about this:GetOperationHandler
(Head/Post/Put/etc.) handle this. It could do an additional request to the store with a differing trailing slash if the first request resulted in a 404. This would increase the amount of requests that is done in case of every 404 though.ResourceStore
adds a field to theRepresentationMetadata
indicating the status code that should be used (but also only works for GET/HEAD since only there metadata gets returned).If we do change the interface of
ResourceStore
, some solutions includeNote that it is recommended to only return 301 for GET/HEAD (and 308 for POST) so there is something to be said for the solutions that would only work with GET/HEAD.
Added in #1064