-
-
Notifications
You must be signed in to change notification settings - Fork 432
Support for relative base path to allow website to be served from different paths #866
Conversation
Did anyone look at the PR ? I saw few people in the same situation as mine in the discord chat and having sapper website being able to be published on IPFS is I think a great feature that should not be discarded too quickly. The changes are not invasive neither. I would love to get feedback if things can be improved so we can have that officially supported Thanks |
I would really appreciate this becoming a part of the package. |
We have several PRs dealing with |
@wighawag thanks for your response in #1208 (comment). I'm responding here so as not to go off-topic discussing this PR in the comments of another PR What I'm wondering is if #984 makes |
This would be super useful - for instance, I am building for a client who will drop the folder wherever they want, and I have no control over where that will end up. It needs to be able to be dropped in anywhere on their server. |
Thanks for putting together this PR! Sapper never had a good method of handling configuration, which made it difficult to know how to integrate this feature. However, that's been addressed in SvelteKit by adding a |
This PR add code to support relative base path so that a website can be hosted on any sub path, including IPFS gateways
This fixes : #746
Note that all url will finish with "/" as this is how ipfs gateways handle folder path
We could potentially add an option to specify a different behavior (remove the slash at the end) if we want but I ll leave that as a potential addition to be done in another PR.
Note that any attempt to access the website pages without a "/" at the end or by specifying "/index.html", will be redirected to the canonical url (with a "/")
This is achieved via
location.replace
Note that it won't solve #863 though as filesystem access has its own problem, push state does not work there and this require to have index.html on every path.
This might be an extra option in the future if we can solve it.
Tests
get a sapper website from the get started guide
and execute the following
You can now serve it from any parent/grandparent folder
Or upload it on ipfs
An example can be found here on cloudflare gateway : https://cloudflare-ipfs.com/ipfs/QmNVTWGZ4qoW4DwiTze3icNJKhKBArR4HrCR1sapAFaPYg/
To show how the website can be loaded from different sub path I also added it to a ENS name. You can use a browser that support ENS or you can use the following link : https://wighawag.eth.link
You can also use a gateway like this : https://cloudflare-ipfs.com/ipns/wighawag.eth.link/
Note that I ll unpin the file and/or update that ENS domain in the future so appologies in advance for future readers :)