qhttpserver
qhttpserver copied to clipboard
cors
how can I add cors information to header?
Hey, you can do this in the code replying for every endpoint the method OPTIONS:
`
if (req->method() == qhttp::EHTTP_OPTIONS)
{
resp->addHeader("Access-Control-Allow-Origin", "*");
resp->addHeader("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS");
resp->addHeader("Access-Control-Allow-Headers", "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With");
resp->setStatusCode(qhttp::ESTATUS_OK);
resp->end();
return;
}
` and you also have to add the same headers in your replies.