Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _redirects file for SPA behavior #28

Closed
lidel opened this issue Feb 22, 2024 · 5 comments
Closed

Add _redirects file for SPA behavior #28

lidel opened this issue Feb 22, 2024 · 5 comments
Assignees
Milestone

Comments

@lidel
Copy link
Member

lidel commented Feb 22, 2024

If we leverage rainbow and dnslink for hosting, we need _redirects for SPA setup in case NGINX 404 logic does not engage correctly.

Does not cost us much, just include static SPA _redirects file in the build output:

Ref. https://docs.ipfs.tech/how-to/websites-on-ipfs/redirects-and-custom-404s/#examples

@SgtPooki
Copy link
Member

SgtPooki commented Feb 23, 2024

What should the content of this _redirects file include? just /* /index.html 200?

this should be able to be added to public/_redirects and automatically be included in the dist folder by webpack

lidel added a commit that referenced this issue Feb 26, 2024
Subdomain gateway won't have any path prefix, namespace and root
identifier are in `Host` header.

Closes #28
@lidel
Copy link
Member Author

lidel commented Feb 26, 2024

I see we already have redirect to root that preserves path (?helia-sw), so acting on that and redirecting back after SW is initialized may be better approach, ensures SW is registered for top level scope.

I've updated rule in in #53 but we need to wire it up in follow-up PR.

@lidel
Copy link
Member Author

lidel commented Feb 26, 2024

Reopening as we still need to wire up handler forthese HTTP 302 with ?helia-sw to preserve path when the first request hits the server without SW being registered yet.

Example:

http://helia-sw-gateway.localhost:3000/ipns/docs.ipfs.tech/how-to/pin-files/ redirects to http://helia-sw-gateway.localhost:3000/?helia-sw=/ipns/docs.ipfs.tech/how-to/pin-files

Rationale: ease of deployment.

I think 302 rule is slightly better than /* /index.html 200 rule because it makes deployment easier by not requiring the backend to be IPFS gateway running in deserialized mode.

HTTP 302 flow will work without backend being IPFS gateway with _redirects support (all you need is to set up nginx config to return index.html for 404 errors and that is all).

@lidel lidel reopened this Feb 26, 2024
@SgtPooki
Copy link
Member

@lidel we shouldn't need ?helia-sw anymore, a simple refresh or redirect to root should work, but if we need "something" for the redirect file to trigger, ?helia-sw will be fine (just ignored, since we don't need it)

@SgtPooki
Copy link
Member

SgtPooki commented Apr 8, 2024

we have e2e first-hit tests for this now and they are successful

@SgtPooki SgtPooki closed this as completed Apr 8, 2024
@SgtPooki SgtPooki added this to the Alpha milestone Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants