decaporg / decap-cms

A Git-based CMS for Static Site Generators

Home Page:https://decapcms.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Force URL trailing slash when loading CMS UI

erquhart opened this issue · comments

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.

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

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.

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.

commented

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)?

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

@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?

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