Skip to content

Commit 6b38be1

Browse files
authored
fix(editor): make CORS requests for 2D guide images for 3D image cache
Add the crossOrigin="anonymous" attribute to the <image> SVG tag used to load the floor plan guide image in the 2D editor. This ensures we get CORS headers back from the server. While they aren't required to display the image in the 2D editor, they are required in the 3D editor, where the image is loaded as a texture. If we don't make a CORS request in 2D and we load the image there first, the response is cached in the browser without the necessary headers. Then, when the 3D editor loads the same URL for the texture, it gets the cached response back without the necessary headers and blows up with a CORS error.
1 parent 75566d5 commit 6b38be1

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

.changeset/polite-garlics-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pascal-app/editor": patch
3+
---
4+
5+
Add the `crossOrigin="anonymous"` attribute to the `<image>` SVG tag used to load the floor plan guide image in the **2D** editor. This ensures we get **CORS** headers back from the server. While they aren't required to display the image in the 2D editor, they _are_ required in the **3D** editor, where the image is loaded as a texture. If we don't make a CORS request in 2D and we load the image there first, the response is cached in the browser without the necessary headers. Then, when the 3D editor loads the same URL for the texture, it gets the cached response back without the necessary headers and blows up with a CORS error.

packages/editor/src/components/editor/floorplan-panel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,7 @@ function FloorplanGuideImage({
28282828
/>
28292829
) : null}
28302830
<image
2831+
crossOrigin="anonymous"
28312832
height={planHeight}
28322833
href={resolvedUrl}
28332834
pointerEvents="none"

0 commit comments

Comments
 (0)