Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.2
Description
One can use "Simple HTTP Server" (Qt\Examples\Qt-6.8.2\httpserver\simple) and "HTTP Client" (Qt\Examples\Qt-6.8.2\network\http) examples to confirm the behavior.
On desktop, everything is fine. Client can receive and handle response from server perfectly. Not so much if the client is built and run as a WASM application. Client always fails due to error 399, i.e. QNetworkReply::ProtocolFailure, when trying to get response from server. On the other hand, browser itself has no such problem.
The reason is that it seems like Cross-Origin Resource Sharing is not allowed. For the response returned by QHttpServer, such header has to be added to make WASM client work (maybe not all of the entries are needed but including all of them certainly works):
QHttpHeaders header; header.append("Allow", "*"); header.append("Access-Control-Allow-Origin", "*"); header.append("Access-Control-Allow-Language", "*"); header.append("Access-Control-Allow-Encoding", "*"); header.append("Access-Control-Allow-Method", "*"); header.append("Access-Control-Allow-Headers", "*"); res.setHeaders(header);
Not sure if it is by design or user is expected to manually enable resource sharing like that.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-133462 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
622432,2 | wasm: document CORS headers for networking | dev | qt/qtdoc | Status: NEW | 0 | 0 |