# Unity 6 WebGL Error

**URL:** <https://community.cesium.com/t/unity-6-webgl-error/46184>\
**Category:** Cesium for Unity\
**Created:** [May 12, 2026, 6:04am UTC](https://community.cesium.com/t/unity-6-webgl-error/46184 "2026-05-12T06:04:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tianyu1008666](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/tianyu1008666/32/28173_2.png) [@tianyu1008666](https://community.cesium.com/u/tianyu1008666)\
**Post date:** [May 12, 2026, 6:04am UTC](https://community.cesium.com/t/unity-6-webgl-error/46184/1 "2026-05-12T06:04:12Z")

</div>

Hello!  
During my use of Cesium for Unity to WebGL。Browser is running with errors. ： Uncaught SyntaxError: Invalid or unexpected token。

The web server is using Nginx. And add\_header Cross-Origin-Opener-Policy same-origin always;  
add\_header Cross-Origin-Embedder-Policy require-corp always;  
add\_header Cross-Origin-Resource-Policy cross-origin always;

The token I used is Default Token。

Could you please explain why this problem occurred?

Unity version：6000.0.26f1c1  
Cesium for Unity version：v1.23.2

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jake/32/33676_2.png) [@Jake](https://community.cesium.com/u/Jake)\
**Post date:** [June 25, 2026, 5:56pm UTC](https://community.cesium.com/t/unity-6-webgl-error/46184/2 "2026-06-25T17:56:32Z")

</div>

Hi @tianyu1008666 ,

Thanks for reaching out and sharing the details of the issue you’re encountering. I can understand how frustrating it can be to deal with browser errors during a WebGL deployment. Let me help troubleshoot.

From your description, the issue could stem from several potential points:

- **Token Issues** : Ensure that the Default Access Token you’re using is valid and properly set up in your Cesium for Unity configuration. You can check this by logging into your [Cesium ion account]( [Cesium ion](https://cesium.com/ion) ) and verifying the token’s status.
- **WebGL Build Settings** : Unity WebGL builds often use compressed assets (e.g., gzip or Brotli). If you’ve enabled compression in your Unity build settings, ensure your Nginx server is configured to properly serve and decompress those files. Unity’s own documentation on [WebGL build publishing]([Unity - Manual: Web Build folder](https://docs.unity3d.com/Manual/webgl-building.html)) outlines common practices.
- **HTTP Headers** : The Nginx headers you’ve specified (`Cross-Origin-Opener-Policy`, `Cross-Origin-Embedder-Policy`, `Cross-Origin-Resource-Policy`) are required for Unity WebGL builds to work with Cesium tiles and assets loaded cross-domain. Double-check if they are applied correctly to all expected resources (e.g., gzipped assets). Also, be aware that misconfigured headers can result in browser errors while loading resources.
- **Browser Console Logs** : If possible, check whether there are additional, more specific error messages in the browser console (e.g., CORS-related errors or issues with MIME types), which may point toward the exact cause.

A relevant discussion on WebGL and Cesium for Unity can be found here: [Does Cesium For Unity support publishing the WebGL version in Unity?](https://community.cesium.com/t/does-cesium-for-unity-support-publishing-the-webgl-version-in-unity/44345) . Let us know if you spot anything in that thread that applies to your setup.

If none of the above resolves your issue, could you try running your WebGL build locally (e.g., with a lightweight server like `http-server`) and confirm if the issue persists without Nginx? Additionally, sharing your Unity WebGL build compression settings (if any) and details on any modifications to the build files (e.g., asset bundles) would be helpful.

Looking forward to your response!
