dotcom-rendering icon indicating copy to clipboard operation
dotcom-rendering copied to clipboard

[Bug]: Assets not loaded when running frontend alongside DCR locally

Open SiAdcock opened this issue 1 year ago • 0 comments

The dev workflow of running DCR alongside frontend is currently broken. We are attempting to load JavaScript assets from the wrong place, so JavaScript doesn't get loaded in this scenario.

You can run both frontend and DCR then hit the frontend port on localhost:

http://localhost:3000

DCR's rendered output generates a relative path with a leading slash that roots the path:

<script type="module" src="/assets/frameworks.client.web.js"></script>
<script type="module" src="/assets/index.client.web.js"></script>

Because you're hitting frontend at localhost:3000, the browser attempts to load asset scripts from:

http://localhost:3000/assets/index.client.web.js

Instead of:

http://localhost:3030/assets/index.client.web.js

First reported here.

@chrislomaxjones suggests taking inspiration from #5285 and #3471

It's possible this is a bug in frontend rather than DCR. If this is the case, we should probably write a check in frontend that loads paths beginning with /assets from localhost:3030 instead of localhost:3000.

SiAdcock avatar Feb 08 '24 19:02 SiAdcock