Sending POST request from Unity WebGL to HTTPS

IEVGEN

I am sending a POST request from a HTTPS page to the following URL:

https://example.com/index.php?fc=module&module=mydemomodule&controller=display

This is the code I use:

IEnumerator CaptureScreenshotAndPost()
{
    byte[] imageBytes = screenImage.EncodeToPNG();
    WWWForm form = new WWWForm();
    form.AddField("hello", "yellow");
    form.AddBinaryData("fileToUpload", imageBytes, "screenShot.png", "image/png");
    UnityWebRequest www1 = UnityWebRequest.Post("https://example.com/index.php?fc=module&module=mydemomodule&controller=display", form);

    yield return www1.Send();

    if (www1.isNetworkError || www1.isHttpError)
    {
        Debug.Log(www1.error);
    }
    else
    {
        Debug.Log("Upload completed!");
    }
}

When the code from above executes, the following error is thrown.

Mixed Content: The page at 'https://www.example.com/index.php?fc=module&module= mydemomodule&controller=display' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.example.com/index.php?fc=module&module= mydemomodule&controller=display?fc=module&module= mydemomodule&controller=display'. This request has been blocked; the content must be served over HTTPS.

IEVGEN

My request was to https://example.com/index.php?fc=module&module=mydemomodule&controller=display, but the domain have redirect to www.example.com, so it redirects it to the HTTP-page with www http://www.example.com/index.php?fc=module&module=mydemomodule&controller=display

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related