Problem/Motivation

Some developers still use tooling like XAMP and won't always use a qualified domain. Instead they will use paths to access the different instances of drupal as seen in the examples below.

  http://localhost/drupal/build/web/admin/modules/browse

  http://localhost/drupal-commerce/build/web/admin/modules/browse

  http://localhost/drupal-7/build/web/admin/modules/browse

When calling the proxy API it tries to qualify the URL against the root domain. As you can see by the attached image below, it causes a 404 that affects the user experience and makes the module unusable.

error image

Steps to reproduce

Create Drupal instances that don't use qualified domains.

Proposed resolution

The way I resolve the issue in Browser Development (this might not be the best option) is to qualify the domain paths using Drupal's backend, then creating a Twig template that adds the true domain being used via Twig template variable and injecting it into the JavaScript as a Global variable. In the example below the template and API completely removes any part of Drupal so the Editor can work independently, so it might not be the best solution in this circumstance.

See the examples below,

https://git.drupalcode.org/project/browser_development/-/blob/9.x-0.x/sr...

  protected function templateVariables() {

   .....

    $this->dataArray = [
      'http_url' => $this->domainPath(), 
      'module_path' => drupal_get_path('module', 'browser_development'),
      'assets_path' => "/assets/build/",
      'api_url' => $url,
    ];
   ....

https://git.drupalcode.org/project/browser_development/-/blob/9.x-0.x/te...

      ...
         window.purencool_editor_config = {
            "global_api_url": "{{data_array.data.http_url}}admin/browser-development/api"
          };
     ...

Remaining tasks

Once the correct option is found in the ticket I am willing to develop and test it, for the project.

CommentFileSizeAuthor
Screen Shot 2021-09-21 at 6.04.47 am.png220.72 KBPurencool
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Purencool created an issue. See original summary.

rlnorthcutt’s picture

Can we confirm that this is a duplicate of https://www.drupal.org/project/project_browser/issues/3227738?

Does that patch fix the issue for you?

chrisfromredfin’s picture

Issue tags: +Project Browser MVP
tim.plunkett’s picture

Status: Active » Closed (outdated)
Issue tags: -Project Browser MVP

None of those code paths exist anymore