Skip to content

Commit 5d727ca

Browse files
committed
Add referer header to Electron apps
Fixes YouTube embeds
1 parent 2be1dae commit 5d727ca

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/packager/packager.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,15 @@ app.on('session-created', (session) => {
735735
cancel: !details.url.startsWith(resourcesURL)
736736
});
737737
});
738+
739+
const referer = 'https://packager.turbowarp.org/referer.html#' + app.getName();
740+
session.webRequest.onBeforeSendHeaders((details, callback) => {
741+
callback({
742+
requestHeaders: {
743+
referer
744+
}
745+
});
746+
});
738747
});
739748
740749
app.on('window-all-closed', () => {

static/referer.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>TurboWarp Desktop Referer</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta name="robots" content="noindex">
8+
<style>
9+
:root {
10+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
11+
}
12+
@media (prefers-color-scheme: dark) {
13+
:root {
14+
color-scheme: dark;
15+
background-color: #111;
16+
color: #eee;
17+
}
18+
}
19+
main {
20+
max-width: 480px;
21+
margin: auto;
22+
}
23+
</style>
24+
</head>
25+
26+
<body>
27+
<main>
28+
<h1>TurboWarp Packager Referer</h1>
29+
<p>If you're seeing requests to your website with this page in its <code>Referer</code> header, that probably means someone is using a program they created with the <a href="/">TurboWarp Packager</a> to interact with your website.</p>
30+
<p hidden class="package-name-outer">The creator of the program set their program's package name to "<code class="package-name-value"></code>". They can set this to anything they want, so that may or may not be meaningful.</p>
31+
<script>
32+
var packageName = location.hash.substring(1);
33+
if (packageName) {
34+
document.querySelector('.package-name-outer').hidden = false;
35+
document.querySelector('.package-name-value').textContent = packageName;
36+
} else {
37+
}
38+
</script>
39+
<p>Per our <a href="privacy.html">privacy policy</a>, we do not track our users and can't tell you who is accessing your website or why.</p>
40+
<p>Questions or concerns? You can email contact at turbowarp dot org, but again, the TurboWarp Packager is just a programming environment. We aren't the people sending requests to your server.</p>
41+
</main>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)