Rendering error: Html received from server instead of JSON

Hi,

Cesium is failing to render in the ‘production’ mode of my Vite-based React app (npm run build; npm run preview)

This is the popup message:

And these two are the exceptions I see in the console:

a)

VM87:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Resource.js:1180:17
(anonymous)	@	Resource.js:1180
Promise.then		
Resource.fetchJson	@	Resource.js:1176
Resource.fetchJson	@	Resource.js:1200
ApproximateTerrainHeights.initialize	@	ApproximateTerrainHeights.js:45
GroundPrimitive.initializeTerrainHeights	@	GroundPrimitive.js:672
DataSourceDisplay	@	DataSourceDisplay.js:44
CesiumWidget	@	CesiumWidget.js:432
Viewer	@	Viewer.js:476
...

b)

An error occurred while rendering.  Rendering has stopped.
InvalidStateError: The source image could not be decoded.
InvalidStateError: The source image could not be decoded.
overrideMethod	@	hook.js:608
CesiumWidget.showErrorPanel	@	CesiumWidget.js:962
CesiumWidget._onRenderError	@	CesiumWidget.js:420
Event.raiseEvent	@	Event.js:139
tryAndCatchError	@	Scene.js:4200
Scene.render	@	Scene.js:4290
CesiumWidget.render	@	CesiumWidget.js:1078
C	@	CesiumWidget.js:60
requestAnimationFrame		
C	@	CesiumWidget.js:61
requestAnimationFrame		
C	@	CesiumWidget.js:61
requestAnimationFrame		
C	@	CesiumWidget.js:61
requestAnimationFrame		
C	@	CesiumWidget.js:61
requestAnimationFrame		
startRenderLoop	@	CesiumWidget.js:87
set	@	CesiumWidget.js:742
CesiumWidget	@	CesiumWidget.js:408
Viewer	@	Viewer.js:476

What could possibly be causing HTML to be returned from the server when the expected response is JSON?

I’m using the latest Cesium version 1.129.0.

Interestingly, there are no compile-time or runtime issues in the dev mode (npm run dev). I assume Cesium should work with Vite, unless officially it’s known not to.

Regards,
/HS