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

  1. Write code
  2. Write docs

API changes

getAllFrontendUrls replaces the current getFrontendUrl method.

Command icon 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

useernamee created an issue. See original summary.

useernamee’s picture

Assigned: Unassigned » useernamee
useernamee’s picture

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

useernamee’s picture

I'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

useernamee’s picture

Assigned: useernamee » fago
Status: Active » Needs review
fago’s picture

Status: Needs review » Needs work

see comments at the PR

useernamee’s picture

Status: Needs work » Needs review

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

fago’s picture

Status: Needs review » Needs work

> 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.

useernamee’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work

thx, 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.

useernamee’s picture

Status: Needs work » Needs review
fago’s picture

thx, changes look good! will give it some test.

fago’s picture

Status: Needs review » Reviewed & tested by the community

tested 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

fago’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.