Last active
March 15, 2022 21:57
-
-
Save michalsnik/7da3858f9ec8782543c65579175e2278 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="remote-browser"></div> | |
<script lang="js"> | |
(async function () { | |
try { | |
const { data } = await fetch("https://<your-api.com>/remote-browser", { | |
method: "POST" | |
}).then(res => res.json()); | |
const iframe = document.createElement('iframe') | |
iframe.src = data.embedURL; | |
document.getElementById("remote-browser").appendChild(iframe); | |
} catch (error) { | |
// Handle error appropriately | |
} | |
})(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The createRemoteBrowser function is an example handler for: POST /remote-browser | |
* It's here for completeness. To ensure your API token remains secure this function | |
* should be part of your backend service. | |
*/ | |
async function createRemoteBrowser() { | |
const apiToken = "<YOUR TOKEN>"; | |
const response = await fetch("https://api.remotehq.com/v1/cb", { | |
method: "POST", | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer ${apiToken}` | |
}, | |
body: JSON.stringify({ | |
browserURL: "https://google.com", | |
kioskModeEnabled: false, | |
incognitoModeEnabled: false, | |
region: "us-east-1", | |
resolution: "medium" | |
}) | |
}); | |
return response.json(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment