简体   繁体   English

将 html5 游戏设置为 iframe

[英]Set a html5 game to an iframe

Im trying to set a html5 game to an Iframe.我正在尝试将 html5 游戏设置为 iframe。

<iframe src="game url"></iframe> 

The problem is the game url needs authentication header (token) and I can't set token on iframe src.(as I know so far)问题是game url需要身份验证标头(令牌),而我无法在 iframe src 上设置令牌。(据我所知)

So I fetched the given game url using axios.所以我使用 axios 获取了给定的游戏网址。 and then passed em to Iframe srcdoc attribute no surprise I got errors.然后将 em 传递给 Iframe srcdoc属性,这并不奇怪我得到了错误。 So what is the solution ?那么解决方案是什么?

here is what I get from the api on postman in which i can send http headers like authentication tokens.这是我从 postman 上的 api 中得到的,我可以在其中发送诸如身份验证令牌之类的 http 标头。 But how can i set it on iframe?但是我如何在 iframe 上设置它?

<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>Cocos Creator | FlappyTest1</title>
   <!--http://www.html5rocks.com/en/mobile/mobifying/-->
   <meta name="viewport"content="width=device-width,user-scalable=no,initial-scale=1, minimum scale=1,maximum-scale=1" />
</head>
<body>
   <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>

   <script src="src/settings.718ea.js" charset="utf-8"></script>
   <script src="main.62040.js" charset="utf-8"></script>
</body>
</html>

Im using React and redux but I think it doesn't matter我使用 React 和 redux 但我认为这无关紧要

I didn't find any solution for this.我没有找到任何解决方案。 Even making a blob from that url doesn't change anything.即使从那个 url 制作一个 blob 也不会改变任何东西。 The solution that I found is kinda related to back-end, where we can pass authentication token as part of url paramaters on src of iframe我发现的解决方案与后端有点相关,我们可以在其中传递身份验证令牌作为src of iframe的 url 参数的一部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM