Closed (fixed)
Project:
Custom Elements
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
25 Aug 2025 at 14:08 UTC
Updated:
9 Oct 2025 at 18:49 UTC
Jump to comment: Most recent
Loading assets from an external domain requires suiting CORS headers. We need either implement some proxy or make it easy on the frontend side to take care of CORS headers. E.g. allow origin with some wildcard-pattern like "*.example.com".
(The risk of allow CORS is rather low if it's only about assets, with that an attacker could basically re-use the assets like we do, to render components on a foreign site, but that's about it. The assets content is public anyway and there is no API that we need to allow, just loading assets.)
Comments
Comment #2
fagoThinking about this topic a 2nd time, the CORS route seems to be better. The proxy-setup is rather complicated and might confuse people much more than a few CORS-requests running in the browser.
For nuxt dev mode, I got CORS working immediately.
For nuxt dev mode the following addition to nuxt.config.ts did the trick (replace origin URL with your drupal base-url obviously):
When running the regular nuxt server, a different configuration is going to be required.
However, a straight-forward configuration as following did not do the trick. Investigating.
Comment #3
fagoFound some working config:
So it seems CORS is really the simpler variant. Let's better clearly document CORS has to be setup correctly + make it easy in our nuxt component-preview helper.
Comment #4
fagothe cors config is actually working fine, so that's the way to go. I documented it as part of https://github.com/drunomics/nuxt-component-preview also.