wails icon indicating copy to clipboard operation
wails copied to clipboard

[V3] CORS Error When Sending Large Data from frontend to backend service

Open xob0t opened this issue 4 months ago • 3 comments

Description

When sending large text data (2MB+) via service calls in Wails v3, the request fails with a CORS policy error. Small payloads (100KB) work fine, but larger payloads consistently fail.

Error Message

Access to fetch at 'http://wails.localhost:9245/wails/runtime?object=0&method=0&args=%7B%22call-id%22%3A%22c62b0aTV1WdzokxYd9SOk%22%2C%22methodID%22%3A2583521458%2C%22args%22%3A%5B%22This+is+a+test+string+for+generating+large+text+data.+This+is+a+test+string+for+generating+large+text+data.+This+is+a+test+string+for+generating+large+text+data...large+text+data.+%22%5D%7D' from origin 'http://wails.localhost:9245' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome-extension, chrome-untrusted, data, edge, http, https, isolated-app.

Analysis

Looking at the error URL, it appears that: The large text data is being URL-encoded and passed as query parameters, creating extremely long URLs that may exceed browser limits https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

To Reproduce

Minimal Reproducible Example

Tested on Windows and Mac, only reproducible on windows https://github.com/xob0t/wails3_cors_error

Expected behavior

Large text data should be successfully sent to the Go service method without CORS errors, just like smaller payloads.

Actual Behavior

  • ✅ Small payloads (100KB) work perfectly
  • ❌ Large payloads (2MB+) fail with CORS error

Screenshots

No response

Attempted Fixes

No response

System Details

Wails (v3.0.0-alpha.12)  Wails Doctor

# System

┌──────────────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                           |
| Version           | 2009 (Build: 19045)                                      |
| ID                | 22H2                                                     |
| Branding          | Windows 10 Pro                                           |
| Platform          | windows                                                  |
| Architecture      | amd64                                                    |
| Go WebView2Loader | true                                                     |
| WebView2 Version  | 138.0.3351.83                                            |
| CPU               | AMD Ryzen 5 5600X 6-Core Processor                       |
| GPU 1             | NVIDIA GeForce RTX 3070 (NVIDIA) - Driver: 32.0.15.7652  |
| Memory            | 32GB                                                     |
└──────────────────────────────────────────────────────────────────────────────┘

# Build Environment 
| WebView2 Version  | 138.0.3351.83                                            |
┌───────────────────────────────┐ 5600X 6-Core Processor                       |
| GOARCH      | amd64           |
| GOOS        | windows         |
└───────────────────────────────┘

# Dependencies

┌────────────────────────────────────────────┐
| npm                        | 10.8.1        |
| NSIS                       | v3.11         |
| MakeAppx.exe (Windows SDK) | Not Installed |
| MSIX Packaging Tool        | Not Installed |
| SignTool.exe (Windows SDK) | Not Installed |
|                                            |
└───────── * - Optional Dependency ──────────┘

# Checking for issues

 SUCCESS  No issues found

# Diagnosis

 SUCCESS  Your system is ready for Wails development!

Additional context

No response

xob0t avatar Jul 17 '25 11:07 xob0t