decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.93k stars 3.04k forks source link

Force URL trailing slash when loading CMS UI #332

Closed erquhart closed 6 years ago

erquhart commented 7 years ago

If the CMS is provided through a file at example.com/admin/index.html, and a user loads it via example.com/admin, the location ends up at example.com/admin#/, and relative paths are relative to root instead of /admin/. This stops the config file from loading, among other things.

React Router may have a config to help with this, but we'll probably just need to force a trailing slash before loading the app.

domachine commented 7 years ago

What about recommending a <base href='/admin/'> in the index.html that loads the admin UI?

erquhart commented 7 years ago

That could help, but it isn't always appropriate, and may actually add confusion for some users. Still feels like we're better off adding the trailing slash and resolving this automatically for all users. We'd probably need to add a config option as well to turn off for odd use cases, but that should be a pretty rare need.

josephearl commented 7 years ago

Related - if you type in the URL with a double // you get a Uncaught DOMException: Failed to execute 'replace' on 'Location': '//#/' is not a valid URL.

tech4him1 commented 7 years ago

Does this actually break anything except loading the config.yml? If not, couldn't we just search both paths (${ currentPath }/config.yml and ${ currentPath }config.yml)?

jacklorusso commented 7 years ago

React Router's Redirect could be used to redirect admin to admin/? If you think this is a decent approach I would be happy to work on it

erquhart commented 7 years ago

@lol-russo my concern on this has been that the CMS has no control over it's environment, so I'd hate to cause regressions by enforcing this. The number one issue behind this symptom is a site generator unexpectedly producing both admin.html and admin/index.html, typically Hugo. I think a better fix might to be to start documenting the issues for each static site generator that has them. We could (and should) have a dedicated page in our docs for individual generators anyway.

Thoughts?

erquhart commented 6 years ago

Pretty sure this isn't something the cms should handle, closing.