79416636

Date: 2025-02-06 02:23:05
Score: 1
Natty:
Report link

The solution to the problem is to add the header res.addHeader("Access-Control-Allow-Origin", "*"); to the HTTP server;

hServer.route("/", QHttpServerRequest::Method::Get, []()
    {
        QString testAnswer = "TEST REPLY";
        res.addHeader("Access-Control-Allow-Origin", "*");  // Added line
        QHttpServerResponse res(testAnswer, QHttpServerResponse::StatusCode::Ok);
        return res;
    });

After adding this line, the browser forwarded the reply to my application.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: leon