Skip to content

Instantly share code, notes, and snippets.

@michalsnik
Last active March 15, 2022 21:57
Show Gist options
  • Save michalsnik/7da3858f9ec8782543c65579175e2278 to your computer and use it in GitHub Desktop.
Save michalsnik/7da3858f9ec8782543c65579175e2278 to your computer and use it in GitHub Desktop.
<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>
/*
* 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