3D Viewer not loading – “Invalid configuration for viewer: Unexpected end of JSON input”

0
Hi everyone,I’m having trouble with the Mendix 3D Viewer. It doesn’t load, and the browser console shows: Invalid configuration for viewer: {}, error: Unexpected end of JSON input I’m using a custom Java HttpRouter to return the viewer configuration as JSON. Even though the router returns {} when there’s no data, the viewer still fails to initialize.It seems the viewer expects a proper JSON structure, and if the controller method returns void or writes directly to the response, the router gets null.Has anyone faced this before? Do I need to always return a JSON string from the controller? Any working example would be super helpful.Thanks!
asked
1 answers
0

Yes, this is a known issue. The 3D Viewer always tries to parse the response as JSON using JSON.parse(). If your router returns null, an empty body, or void, the viewer fails with "Unexpected end of JSON input".


The fix is simple: always return a valid JSON response.


  • Never return void
  • Always return at least {} (or a minimal valid configuration)
  • Make sure the response has Content-Type: application/json


This behavior is also implied in the 3D Viewer Installation and Configuration documentation, where the viewer configuration is described as an advanced configuration in JSON string format with specific properties. In other words, the viewer is explicitly designed to receive and parse JSON. If the response body is empty or invalid JSON, the browser’s JSON parser will fail and the viewer cannot initialize.


answered