Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UnityWebRequest and SSL certificate issues with WebGL builds

Discussion in 'Multiplayer' started by ElnuDev, Apr 27, 2020.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I'm having a problem with
    UnityWebRequest
    in WebGL builds. I understand that there are issues mixing HTTP and HTTPS connections, so I got a Let's Encrypt Authority X3 HTTPS SSL certificate for the site I'm using to host my highscores. However, I'm still having problems. Does anyone know how to fix this? Do I need to wait 24 hours or something for it to process? The weird thing is that in Opera GX it says "Not Secure" even though it states the certificate is "Valid", but in Google Chrome it has no problem with it. So... what's going on? Thanks in advance!
     
  2. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I've found the solution! It might be a bit hacky, but it works. I found out by accident that the way itch.io embeds the web versions of games into the page seems to be using an
    iframe
    , and putting links within it will display within the frame instead of actually opening the page. So with this knowledge, I tried making a JavaScript redirect to the page on my site:

    Code (JavaScript):
    1. <!DOCTYPE html>
    2.  
    3. <html>
    4.    <head>
    5.        <script>
    6.            window.onload = function () {
    7.                window.location.href = "my game's url";
    8.            }
    9.        </script>
    10.    </head>
    11. </html>
    And it worked like a charm! What's more, the highscores work as well! I haven't tested browser compatibility yet, but I don't see why it shouldn't work.