enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Redirect webapp url if it doesn't end with / #7087

Open alansemenov opened 5 years ago

alansemenov commented 5 years ago

Something we talked about for a very long while but apparently have never implemented. If webapp url doesn't end with "/", we should redirect from webappUrl to webappUrl/. This now causes a lot of issues with PWAs where we have to implement client-side redirect to not have to store assets twice (webapp and webapp/are two different scopes).

Consider doing the same for site url without vhost.

sigdestad commented 5 years ago

NB! When using vhosts, this is not a problem, so this only relates to cases where the url is used directly. Test out carefully that this does not affect webapps deployed through vhosts.

NB! Also try out how this works for vhosts with subpath i.e. myapp.com/app etc.

The purpose is simply that we don't want webapp developers to build custom code to handle development specific problems.

sigdestad commented 5 years ago

Also, would be nice with some considerations on how this might affect admin tools as well. i.e. what if content studio was a PWA.

GlennRicaud commented 4 years ago

Not a fan of this idea. This seems to be a case very specific to PWA. Not sure that we should force this behaviour on all webapps. Putting it to backlog for discussion

sigdestad commented 4 years ago

Thought this was already done?

rymsha commented 3 years ago
  1. It would be breaking, because some may already use webapp without a slash.
  2. it is trivial for PWA developers to implement using lib-router 3.0.0 on XP 7.7.1
    libRouter.get('/?', req => {
    if (!(req.rawPath || '').endsWith('/')) {
        return {
            redirect: req.path + '/'
        }
    }
    return {
        body: ...

So, I don't see a great demand for this anymore.

sigdestad commented 3 years ago

I think this is already implemented for webapp root? But really nice to control this via app code anyway.

Are we able to run a filter that do such rewrites in the site engine as well? As in before pages are rendered?

rymsha commented 3 years ago

No redirection happens right now (at least XP does not do it).

Next question is to @espen42 who gained quite a bit of knowledge (And it is out of topic in this issue)