Problem/Motivation
The sub-directory/folder issue of Drupal base path and Drupal root path
Steps to reproduce
Given that the Project Browser module was installed on the standard recommended Drupal 9 build with the following directory physical path "/var/www/html/dev/drupal9project_browser"
But no direct domain to point at the folder "/var/www/html/dev/drupal9project_browser/web"
When navigating to "http://localhost/dev/drupal9project_browser/web/admin/modules/browse" URL
No data is loading
And that indicates more issues with Drupal routes + Svelte routes
private and public permissions to access the Svelte app Routes
And when the site is working with another languages as the default language with a sub path
Proposed resolution
Pass the site:origin-url
not the site:url
to the Svelte App script
Add a session key for Svelte App routes
The Origin URL: Origin URL (scheme and HTTP host) of the site. No language prefix.
// Until #1088112: Introduce a token to get site's base URL is
// committed,
// https://www.drupal.org/project/drupal/issues/1088112
// let's use a custom token. Let's call it: [site:origin-url].
// No language prefix in the url.
// -----------------------------------------------------------------
/** @var \Symfony\Component\HttpFoundation\Request $origin_url */
$origin_url = \Drupal::request()->getSchemeAndHttpHost() . \Drupal::request()->getBaseUrl();
origin_url could be used in the Svelte App or any other script.
Not to fall into issues like #1088112: Introduce a token to get site's base URL
Remaining tasks
- ✅ File an issue about this project
- ✅ Pass the
site:origin-url
not thesite:url
to the Svelte App script - ✅ Testing to ensure no regression
- ❌ Automated unit/functional testing coverage
- ❌ Developer Documentation support on feature change/addition
- ❌ User Guide Documentation support on feature change/addition
- ❌ Code review from core team member
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review
- ❌ Release
User interface changes
- None
API changes
- APIs for Apps will be under the Drupal Routing, session, and permission control
Data model changes
- None
Comments
Comment #2
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #3
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #4
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #5
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #6
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #7
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #8
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThis patch is passing
origin_url
to thedrupalSettings.project_browser
So it could be used as
drupalSettings.project_browser.origin_url
in routes and assetsExample with routes:
Example with assets:
It could be that it fixes the
Named the passed value as origin_url, which for sure can be changed.
The Origin URL: Origin URL (scheme and HTTP host) of the site. No language prefix.
Comment #9
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #10
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #11
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #12
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #13
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedWould you like to keep the origin_url name for the argument.
Thanks a lot :)
Learned new things to get to this point for this fix.
Comment #14
rlnorthcuttThis seems like a very clean solution overall.
One thing: the patch includes the Svelte bundle and output. This makes sense for the actual PR we need, but perhaps we should break Svelte related work into two patches? One for the component/code changes and one for the whole thing? I know it's a pain to take the extra step, but it will make it much simpler to review.
Comment #15
rlnorthcuttSide note: perhaps we should file a core issue to see about getting something like "drupalSettings.origin_url" put in place. It seems like a really powerful and useful thing that core could provide for any JS tool.
Comment #16
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThanks, Ron
I do agree with the
drupalSettings.origin_url
in core#1088112: Introduce a token to get site's base URL
Hoping to be committed to the core. Or a new issue for the JS passing of new origin_url value.
About the Svelte bundle and output. Noted on that.
I'm still learning .. and thinking of ways to attach postcss and CSS files in .svelte files
or at least in the process of building.
Comment #17
chrisfromredfinIs #3236846 a related issue to this? Can one be marked as a dupe of the other?
Comment #18
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedFollowing up on #14
Having 2 new parted patches
project_browser-3227738-18.patch
project_browser--Svelte-bundle-and-output--3227738-18.patch
Comment #19
rlnorthcutt@Chris - I think so? I asked on the other issue to see if they can test/confirm.
@Rajab - considering that there is a core issue open, perhaps we should contribute there and include the patch in our module composer file (that works, right?). That way we can contribute to the core patch we will ultimately want/need, and it looks like there are a few more edge cases noted there. Better coverage and attention there.
Plus, I may be able to get that on the radar of some core folks when we feel like it is ready for final review.
Comment #20
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedNoted;
Following on that in the Drupal core issue
#1088112: Introduce a token to get site's base URL
Comment #21
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedNot sure when #1088112: Introduce a token to get site's base URL will be committed to Drupal core
I recommend fixing this in the current working module.
Comment #22
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #23
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #24
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #25
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #26
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #27
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #28
gaurav.kapoor CreditAttribution: gaurav.kapoor at Axelerant commented@RajabNatshah Thanks for providing the patch, the project browser wasn't working for me in the local but started working after applying the patch provided in #27.
Also, any reason of appending \Drupal::request()->getBaseUrl() in the line
\Drupal::request()->getSchemeAndHttpHost() is returning the required base path which has to be added before URLs in the Svelte app. Will it needed for any particular kind of setup?
Comment #29
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThis is for when the site is in
http://
orhttps://
To work on the current configured hosting protocol settings
Comment #30
gaurav.kapoor CreditAttribution: gaurav.kapoor at Axelerant commentedOk. Cool. Tested #27 and it fixes timeout or no record issues resulting from wrong paths.
Comment #32
chrisfromredfinpushed to 1.0.x! Thank you all!