-
Notifications
You must be signed in to change notification settings - Fork 83
Multi Channel Context Routing
-
how do we do multi-site?
- dynamic configuration with URL Params
- handled in nginx before SSR
- domain switching:
- de.myshop.com, myshop.de -> German language & German channel
-
describe limitation of Angular
- wants to take control of whole route after domain -> dynamic configuration only per domain
- possible to set baseHref and deployUrl, but build time setting
- APP_BASE_HREF injection token
-
-> not easily possible to include context-path in multi site handling
- there probably won't be a standard solution, so it should not intervene too much in code over all
- probably best if just deployment
- reduce deployment cost
- build different PWAs
- configured via angular.json configurations
- PWA docker build must be made multiple times -> one deployment per context with own configuration
- custom nginx config to upstream to different PWAs
π no Angular code modification
π properly switch-able with ingress (Kubernetes)
π additional deployment slots needed
π not exactly multi-channel as reducing deployment cost was a goal
π€·ββοΈ custom nginx configuration
still recommended?: βοΈ - This is probably the cleanest solution
- build PWA with multiple contexts
- import those Universal apps into express.js and switch middlewares via incoming paths
π no Angular code modification
π all hell breaks loose in server.ts
π multi-site handling in nginx gets annulled
still recommended?: β
- hacky solution like this: https://stackoverflow.com/a/39084260
- I did not get it working
π not that much Angular code modification
π all hell breaks loose in server.ts
(managing custom context-paths)
π€·ββοΈ custom nginx configuration
still recommended?: β
-
routing must be adapted in
app-routing.module
and all extensions. -
possibly wrap all routes in
RouterModule.forX
configuration for maintainability -
SEO compatibility?
- either generate all routes correctly with context path
-
every
routerLink
androuter.navigate
π
-
every
- or no SEO compatibility
- add a guard, that adds context if it is missing
- either generate all routes correctly with context path
π heavy Angular code modification either way
π multi-site handling in nginx gets annulled
still recommended?: β
- remove baseHref from index.html and supply it adaptively
- supply the SSR process with APP_BASE_HREF
- on outgoing response add
<base href='sth'/>
tag to html head. << hack - client-side application is configured with proper baseHref
- nginx makes multi-channel configuration
π few Angular code modification, few code modification overall
π not switch-able with ingress (Kubernetes), because deployUrl is not set. Everything depends on /
π€·ββοΈ custom nginx configuration
π€·ββοΈ a hack is still a hack
still recommended?: βοΈ - This is probably the neatest solution, but still a hack π
- it should be possible to pass in the configuration which is built in the Dockerfile as an argument