Skip to content

Commit d54425a

Browse files
committed
ipip-386: editorial fixes
1 parent 50c4ea9 commit d54425a

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

IPIP/0386-gateway-interop-redirects.md renamed to src/ipips/ipip-0386.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# IPIP-386: Subdomain Gateway interop with _redirects
2-
3-
<!-- IPIP number should match its pull request number. After you open a PR,
4-
please update title and include anqabbreviated title in the filename too:
5-
`0000-draft-title-abbrev.md`. -->
6-
7-
- Start Date: 2023-03-18
8-
- Related Issues:
9-
- IPIP-2 _redirects file
1+
---
2+
title: "IPIP-0386: Subdomain Gateway Interop with _redirects"
3+
date: 2023-03-18
4+
ipip: proposal
5+
editors:
6+
- name: suicide
7+
github: suicide
8+
relatedIssues:
9+
- https://github.com/ipfs/boxo/pull/326
10+
- https://github.com/ipfs/boxo/pull/412
11+
order: 386
12+
tags: ['ipips']
13+
---
1014

1115
## Summary
1216

13-
<!--One paragraph explanation of the IPIP.-->
14-
This IPIP suggests a tweak in the Path and Subdomain Gateway interop to
15-
leverage the `_redirects` file.
17+
This IPIP clarifies the Path and Subdomain Gateway interop to
18+
ensure features like `_redirects` file work correctly.
1619

1720
## Motivation
1821

@@ -22,7 +25,7 @@ On traditional hosting, deep links are redirected or rewritten to a single
2225
entry point, e.g. `/index.html`, and the router on the client side evaluates
2326
the path segments to render the correct content.
2427

25-
The `_redirects` file, defined in [`REDIRECTS_FILE.md`](../REDIRECTS_FILE.md),
28+
The `_redirects` file, defined in :cite[web-redirects-file],
2629
supports such applications when a Subdomain Gateway is used directly. However,
2730
the current resolution of native URLs uses a Path Gateway link scheme and
2831
subsequently fails to resolve the URL correctly.
@@ -33,7 +36,7 @@ For example:
3336
- `http://{gateway}/ipns/example.org/some/path`
3437
- this request fails with 404 as the resource `/some/path` does not exist.
3538

36-
NOTE: The `kubo` gateway returns a 404 including a new `Location` header
39+
NOTE: The `kubo` (<0.20) gateway returns a 404 including a new `Location` header
3740
already pointing to the correct subdomain URL. But browsers do not follow the
3841
header as the status is 404, and the response contains a `text/plain` body
3942
string.
@@ -73,7 +76,7 @@ not found in the directory identified by the CID or DNSLink name.
7376

7477
## Test fixtures
7578

76-
The example from the [REDIRECTS_FILE.md](../REDIRECTS_FILE.md) can be re-used,
79+
The example from the :cite[web-redirects-file] can be re-used,
7780
`QmYBhLYDwVFvxos9h8CGU2ibaY66QNgv8hpfewxaQrPiZj`.
7881

7982
```
@@ -115,14 +118,14 @@ $ curl -v http://{gateway}/ipfs/QmYBhLYDwVFvxos9h8CGU2ibaY66QNgv8hpfewxaQrPiZj/r
115118
...
116119
```
117120

118-
Subsequent requests should comply with IPIP-2.
121+
Subsequent requests should comply with :cite[ipip-0002].
119122

120123
## Design rationale
121124

122-
Gateways like `kubo` already support the suggested redirect but block the
123-
redirect chain by returning a 404 when a resource is not found on the Path
124-
Gateway. By removing the 404, users get another chance to find the resources
125-
they are looking for.
125+
Gateways like `kubo` (before v0.20) already support the `_redirect` and
126+
subdomain redirect, but block the redirect chain by returning a 404 when a
127+
resource is not found on the Path Gateway. By moving the 404 to occur at the
128+
subdomain, users get another chance to find the resources they are looking for.
126129

127130
### User benefit
128131

@@ -134,15 +137,17 @@ compatibility.
134137

135138
### Compatibility
136139

137-
This proposal improves the reach of `_redirects` files.
140+
This proposal fixes a bug in handling of `_redirects` files.
138141

139-
The current behavior is defined in [PATH_GATEWAY.md](../PATH_GATEWAY.md). The
142+
The current behavior is defined in :cite[path-gateway]. The
140143
404 return code indicates that a resource does not exist. Changing this to a
141144
301 redirect that is subsequently answered with a 404 from the subdomain URL
142-
might break clients.
145+
is a breaking change, but the old behavior should be considered as a bug.
146+
147+
Requesting an existing resource on the Path Gateway URL in `kubo` already
148+
returns a 301 redirect: client expectation is for the behavior to be the same
149+
for invalid paths.
143150

144-
However, requesting an existing resource on the Path Gateway URL in `kubo`
145-
already returns a 301 redirect while also providing the content in the body.
146151

147152
### Security
148153

@@ -154,7 +159,8 @@ security due to host separation.
154159

155160
Gateways could continue to return a 404 response for the non-existing resource,
156161
but also include an HTML body containing a redirect link. This would help users
157-
to find the requested site.
162+
to find the requested site, but comes with worse UX than the fix proposed in
163+
this IPIP.
158164

159165
### Copyright
160166

0 commit comments

Comments
 (0)