Problem/Motivation
Add a central API for frontend urls. These could be used for CORS policy or content security policy.
Proposed resolution
Add lupus_decoupled.frontend_base_urls service parameter that could be extended/overridden by custom service providers and a method BaseUrlProvider::getAllFrontendBaseUrls that returns the value.
Remaining tasks
- Write code
- Write docs
API changes
getAllFrontendUrls replaces the current getFrontendUrl method.
Issue fork lupus_decoupled-3316363
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
useernamee commentedComment #3
useernamee commentedI was planning to implement a container parameter for front-end urls, but lupus decoupled already has these in the configuration. I'm wondering whether I should have this side by side with container parameter taking precedence or just replace current config solution altogether?
Comment #5
useernamee commentedI've added a concept MR to work on from it. It is implementing current config solution but overrides it with the container parameter. I think that currently frontend_urls are configured on to many places.
This ticket also takes care of #3320798: Support CORS headers for multiple frontends
Comment #6
useernamee commentedComment #7
fagosee comments at the PR
Comment #8
useernamee commented@fago thank you for comments. I've sorted priorities now and the logic goes like that:
FrontendBaseUrl is retrieved from configuration but can be overridden with DRUPAL_BASE_URL environment variable. Additional front-end urls can be appended with lupus_decoupled_ce_api.frontend_base_urls container parameter.
I have two things to sort out:
1. is DRUPAL_BASE_URL good naming for the env var?
2. Should we add this into README or somewhere else as a documentation?
Comment #9
fago> 1. is DRUPAL_BASE_URL good naming for the env var?
No, that would be the base URL for the drupal backend if anything. I think it should be DRUPAL_FRONTEND_BASE_URL
I reviewed the MR. Else it looks really good now, I just added a suggestion for some small comment addition. So let's rename the variable and we should be ready to go here.
Comment #10
useernamee commentedComment #11
fagothx, sry took me a while to get back to this one.
MR looks pretty good already, but there are a couple of places that need little love, see my comments.
Comment #12
useernamee commentedComment #13
fagothx, changes look good! will give it some test.
Comment #14
fagotested it works all good. also CORS headers keep working. only minor thing I found and corrected was a missing |null return type in code comment
Comment #16
fago