-
Notifications
You must be signed in to change notification settings - Fork 188
App only works when hosted within the root directory of a domain #27
Description
My clone of animal-kingdom only works if accessed through a URL like: https://mydomain.test/index.html it does not work if accessed through a URL like https://mydomain.test/some/other/path/index.html
There are two classes of reason why:
-
The Blockstack redirectToSignIn API is called with no parameters, meaning it uses the default manifest location (so manifest.json is expected to be at the root of the current domain). Note: I tried fixing this by changing line 15 of Landing.js from:
this.userSession.redirectToSignIn()
to:
this.userSession.redirectToSignIn(window.location.href, window.location.href.replace(//[^\/]*$/, '/manifest.json'))
but it did not work, maybe the manifestURI parameter documented at https://blockstack.github.io/blockstack.js/#redirecttosignin is being ignored? -
Throughout the application code, hrefs are created with a beginning slash, e.g.:
App.js - window.location =/kingdom/${userData.username}
EditMe.js -
Kingdom.js - style={{backgroundImage:url('${app}/territories/${rulerTerritory.id}.jpg')}}
NavBar.js - Animals
...
Ideally these hrefs would be constructed relative to the initial URL used to render the app.
It will be much easier for people to fork and modify the app if it can be rendered from within sub-folders. For example, I wanted to commit my build folder to Git so I could just easily host my builds through GitHub pages, but I had to give up on that approach.