linagora / esn-frontend-common-libs

Common ground for OpenPaaS frontend (https://open-paas.org)
Other
4 stars 12 forks source link

switch to html5mode (old browser) replacing hash strategy #199

Closed fabienmoyon closed 2 years ago

fabienmoyon commented 3 years ago

 context

With oidc setup, oidc providers doesnt support hash (e.g keycloak).

to do

Wwe will have to replace fragment URI (angularjs router) ex: http://localhost:9900/inbox/#/auth/oidc/callback to http://localhost:9900/inbox/auth/oidc/callback

we will have to talk about it. If we directly switch to html5mode (old browser) replacing hash strategy or if we can mix strategy

alagane commented 3 years ago

Seems it is already enabled in some projects. This issue is also about it: https://github.com/linagora/esn/issues/16 Need to investigate

alagane commented 3 years ago

Where Do We Serve Files

Images shoud be served after {PREFIX}/images (said by Andy)

Example Values

FRONTEND_URL: inbox.open-paas.org.local PREFIX: inbox/

Should prefix contain leading and trailling slash?

About base href (tested on Firefox)

Base href has no effect on absolute urls ({FRONTEND_URL}/{PREFIX}myresource) root-relative urls (example /{PREFIX}myresource) It default value is the current path Leading slash not needed (same behaviour with and without), but if 2 leading slashes, it uses it as url and not prefix (same scheme). Trailing slash needed, if omitted the last base href path part is ignored, and if 2 trailing slahes, 2 appears in the links.

Conclusion

Should use a trailing slash and no leading slash, example is inbox/ We also could use no trailing and leading slashes, and just add on trailing slash on base href. It would also make it easier to redirect {PREFIX} to {PREFIX}/

Where Do We Serve Files

{FRONTEND_URL} should redirect to {FRONTEND_URL}/{PREFIX} Omitting the trailing slash of prefix should redirect to {FRONTEND_URL}/{PREFIX} For redirections, we could use nginx templates.

index.html

Without html5Mode (no history API)

index.html should be served on {FRONTEND_URL}/{PREFIX} On every url ({FRONTEND_URL}/{PREFIX}#...) the base href is the prefix, because the rest of the url is considered as an anchor.

With html5Mode (history API)

index.html should be served on {FRONTEND_URL}/{PREFIX}*

Base href should be set as soon as possible, after loading the /env/openpaas.js Or the base href value could be set directly on index.html when starting the docker image (modifying the file) Or nginx could take care of replacing base href value when serving the index.html (with sub_filter for example http://nginx.org/en/docs/http/ngx_http_sub_module.html)

env/openpaas.js

2 solutions

Serve at root

env/openpaas.js should be served on {FRONTEND_URL}/env/openpaas.js We load it from /env/openpaas.js, same path whatever is the current path.

Serve at prefix

env/openpaas.js should be served on {FRONTEND_URL}/{PREFIX}env/openpaas.js If we load it from env/openpaas.js, with Html5mode, it would work if we land on {FRONTEND_URL}/{PREFIX} (we could serve it on {FRONTEND_URL}/{PREFIX}/env/openpaas.js) but would not work if we land on {FRONTEND_URL}/{PREFIX}path/to/page for example. Another solution would be to use root-relative url, cannot serve it on /{PREFIX}env/openpaas.js because we do not know the prefix before this file is read (except if we replace/modify index.html before serving it).

Images

They should be served on {FRONTEND_URL}/{PREFIX}images/... They should be loaded from images/... or using root-relative urls from /{PREFIX}images/... This would need to know the correct prefix.

tanandy commented 3 years ago

cc @chamerling

rezk2ll commented 3 years ago

Why do we need a prefix if each SPA is in its own subdomain?

instead of inbox.open-paas.org.local/inbox/ we just use inbox.open-paas.org.local and the application starts serving from there.

tanandy commented 3 years ago

no we dont do that inbox.open-paas.org.local is just and example. we need to keep the prefix for the spa for different reason bucket / cdn / code ....

fabienmoyon commented 3 years ago

We can have the flexibility to use SPAs on the same domain or not

tanandy commented 3 years ago

exactly, thats the usage of the base href