Iframe loading and redirections

I’m trying to make a GODOT game play inside of an iframe, I have the website and iframe deployed to netlify.

The website url: “https://jenaroo.netlify.app/
The game url: “https://godotcvgame.netlify.app/

It’s using netlify redirect rules to load the game and avoid cross origin issues from “jenar.ooo” to the game url

  • The Issue *
    The iframe loads the html content from https://godotcvgame.netlify.app/ which in turn is loading a script from a tag with src “index.js” but the index.js is trying to load from “siteURL/index.js” instead of “siteURL/game/index.js”.

My rules are like so:

[[redirects]]
force = true
from = “/game/*”
status = 200
to = “https://godotcvgame.netlify.app/:splat

Is there a way to stop this from happening?

This support guide will probably help:

https://answers.netlify.com/t/support-guide-handling-cors-on-netlify/107739#h-321-for-static-assets-6

Thanks Nathan, but I’m not having any CORS issues now that I’m redirecting, do you mean that I shouldn’t do the redirections like I am?

@cjenaro The proxy doesn’t change the route/file being served, it just passes it through.

On the actual page:
https://godotcvgame.netlify.app/

You are now loading:
src="index.js"

When I posted my previous response, you were loading:
src="https://godotcvgame.netlify.app/index.js"

Your original post indicates perhaps you started with:
/index.js

As you’ve noticed using /index.js or index.js with the proxy won’t work.

It’s easy to confirm this by skipping the iframe and going directly to:
https://jenaroo.netlify.app/game

Since the proxy causes that file to load at that location, it looks for:
https://jenaroo.netlify.app/index.js → which doesn’t exist

As you’re using index.js now which is relative, accessing:
https://jenaroo.netlify.app/game/

Causes it to try and load:
https://jenaroo.netlify.app/game/index.js → which also doesn’t exist

So your options would be:

  • Continue adjusting the original content and the proxy until they align such that the files are loadable
    E.g. If the original content loaded its resources from /game/ it’d be easier to match up
  • Use absolute URL’s and then follow the documentation I linked to adjust headers for CORS