Skip to content

[4.x]: Various CP JavaScript errors with CP on different domain #13628

@baileydoestech

Description

@baileydoestech

What happened?

Description

I suspect this is a result of hosting our CP on a different domain to the primary site, we are seeing some strange JavaScript errors in the CP.

Steps to reproduce (using DDEV but reproducible in an AWS environment as well)

  1. Standard Craft installation using DDEV with CP on separate domain to main site i.e.
    BASE_CP_URL="https://admin.ddev.site"
    PRIMARY_SITE_URL="https://main.ddev.site"

  2. Add NGINX configuration to allow CORS
    `
    location ~* .(?:js?)$ {
    add_header Access-Control-Allow-Origin "*";
    }

Expected behavior

JS bundles should load as expected in the CP and not cause any console errors

Actual behavior

We see the following issues:

  1. Attempting to create a new matrix block throws a console error (only when selecting the Matrix field type): Uncaught TypeError: Craft.MatrixConfigurator is not a constructor. This prevents any model dialog from rendering (i.e. when adding a new block type), can workaround this by trying to save the field, which fails, and then the model will appear as expected (no JS error anymore)
    image
    Once reloaded the 'bubble' appears
    image

  2. Similar issue seen with the Image Resizer plugin, I had raised this in Uncaught TypeError ResizeElementAction verbb/image-resizer#77 but given the above wondering if the problem is more Craft related?

  3. When adding new entries field, we see Uncaught ReferenceError: htmx is not defined, possible that this is coming from the Sprig plugin (that's the only thing I can think of using htmx?) but odd this only affects the entries selection?
    image

  4. We also see the above when selecting blocks inside a Vizy field
    image

Craft CMS version

Craft Pro 4.5.3

PHP version

8.2.9

Operating system and version

Linux

Database type and version

MariaDB 10.4.30

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions (all latest)

  • Amazon S3
  • AsyncQueue
  • CKEditor
  • Feed Me
  • Formie
  • ImageOptimize
  • Image Resizer
  • Retour
  • SEOMatic
  • Sprig
  • Super Table
  • Vite
  • Vizy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions