ArduCAM / ArduCAM_ESP32S_UNO

ArduCAM ESP32 Series Development Boards
52 stars 19 forks source link

CORS header missing #11

Open TimotF opened 5 years ago

TimotF commented 5 years ago

Hi,

I'm having an issue getting the capture example running : when the GET request is sent to the ESP32, I get the response

Server is running!

URI: /a Method: GET Arguments: 3

QL change to: 2

But at the same time, I get an error on the console saying that a CORS request has been blocked as the CORS header was missing. I tried with 3 different browser (firefox, edge, chrome) but without success (still can't get the image from the camera)...

TimotF commented 5 years ago

For anyone having the same isue : try to add the following line server.sendHeader("access-control-allow-origin","*");

The complete handleNotFound function should be :

void handleNotFound() {
  String message = "Server is running!\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  server.sendHeader("access-control-allow-origin","*");
  server.send(200, "text/plain", message);
  Serial.println(message);

  if (server.hasArg("ql")) {
    int ql = server.arg("ql").toInt();
#if defined (OV2640_MINI_2MP) || defined (OV2640_CAM)
    myCAM.OV2640_set_JPEG_size(ql);
#elif defined (OV5640_MINI_5MP_PLUS) || defined (OV5640_CAM)
    myCAM.OV5640_set_JPEG_size(ql);
#elif defined (OV5642_MINI_5MP_PLUS) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) ||(defined (OV5642_CAM))
    myCAM.OV5642_set_JPEG_size(ql);
#endif

    Serial.println("QL change to: " + server.arg("ql"));
  }
}
fcham commented 4 years ago

No, the problem is the same...