dynamic domain fetch in app
This commit is contained in:
parent
89953a70f3
commit
647649f9d9
Binary file not shown.
@ -1,28 +0,0 @@
|
|||||||
// (A) CREATE/INSTALL CACHE
|
|
||||||
self.addEventListener("install", evt => {
|
|
||||||
self.skipWaiting();
|
|
||||||
evt.waitUntil(
|
|
||||||
caches.open("Demo")
|
|
||||||
.then(cache => cache.addAll([
|
|
||||||
"index.html",
|
|
||||||
"manifest.json"
|
|
||||||
//"YOUR-STYLES.css",
|
|
||||||
//"YOUR-SCRIPTS.js",
|
|
||||||
//"YOUR-IMAGES.jpg"
|
|
||||||
]))
|
|
||||||
.catch(err => console.error(err))
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// (B) CLAIM CONTROL INSTANTLY
|
|
||||||
self.addEventListener("activate", evt => self.clients.claim());
|
|
||||||
|
|
||||||
// (C) LOAD FROM CACHE FIRST, FALLBACK TO NETWORK IF NOT FOUND
|
|
||||||
self.addEventListener("fetch", evt => evt.respondWith(
|
|
||||||
caches.match(evt.request).then(res => res || fetch(evt.request))
|
|
||||||
));
|
|
||||||
|
|
||||||
/* (C) LOAD WITH NETWORK FIRST, FALLBACK TO CACHE IF OFFLINE
|
|
||||||
self.addEventListener("fetch", evt => evt.respondWith(
|
|
||||||
fetch(evt.request).catch(() => caches.match(evt.request))
|
|
||||||
));*/
|
|
||||||
@ -1,50 +1,91 @@
|
|||||||
<html><head> <meta charset="utf-8">
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" name="viewport">
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" name="viewport">
|
||||||
|
|
||||||
<!-- section:seometa -->
|
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:site_name" content="Discord">
|
<meta property="og:site_name" content="Discord">
|
||||||
<meta property="og:title" content="Discord - A New Way to Chat with Friends & Communities">
|
<meta property="og:title" content="Discord - A New Way to Chat with Friends & Communities">
|
||||||
<meta property="og:description" content="Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities."><meta property="og:image" content="https://discord.com/assets/ee7c382d9257652a88c8f7b7f22a994d.png"> <meta name="twitter:card" content="summary_large_image">
|
<meta property="og:description" content="Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.">
|
||||||
|
<meta property="og:image" content="https://discord.com/assets/ee7c382d9257652a88c8f7b7f22a994d.png">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<meta name="twitter:site" content="@discord">
|
<meta name="twitter:site" content="@discord">
|
||||||
<meta name="twitter:creator" content="@discord">
|
<meta name="twitter:creator" content="@discord">
|
||||||
<!-- endsection -->
|
|
||||||
<link rel="stylesheet" href="/assets/0.2b34836c33685cfed2cb.css" integrity="sha256-M5Vesh6YIz/Jhf7SDMllTJUN0sVnnsYMC1t5b0PgtrI= sha512-rMHRh3OkIAbI/gag1X+v6D4f9jbW1Qpx0Xl9f81B7KO+sXxoWdp53/IOfsfOCdYZDDhAuLZVq8+rbJln0x5ZMw=="><link rel="icon" href="/assets/07dca80a102d4149e9736d4b162cff6f.ico"> <!-- section:title -->
|
|
||||||
<title>Discord</title>
|
|
||||||
<!-- endsection -->
|
|
||||||
<link rel="manifest" href="/assets/manifest.json">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
<link rel="stylesheet" href="/assets/0.2b34836c33685cfed2cb.css">
|
||||||
<div id="app-mount"></div><script nonce="">window.__OVERLAY__ = /overlay/.test(location.pathname)</script><script nonce="">window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname)</script><script nonce="">window.GLOBAL_ENV = {
|
<link rel="icon" href="/assets/07dca80a102d4149e9736d4b162cff6f.ico">
|
||||||
API_ENDPOINT: '//localhost:3001/api',
|
<link rel="manifest" href="/assets/manifest.json">
|
||||||
WEBAPP_ENDPOINT: '//localhost:3001',
|
<title>Discord</title>
|
||||||
CDN_HOST: 'localhost:3001',
|
|
||||||
ASSET_ENDPOINT: 'http://localhost:3001',
|
<script>
|
||||||
MEDIA_PROXY_ENDPOINT: 'http://localhost:3001',
|
(function() {
|
||||||
WIDGET_ENDPOINT: '//discord.com/widget',
|
window.GLOBAL_ENV = {};
|
||||||
INVITE_HOST: 'discord.gg',
|
window.__OVERLAY__ = /overlay/.test(location.pathname)
|
||||||
GUILD_TEMPLATE_HOST: 'discord.new',
|
window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname)
|
||||||
GIFT_CODE_HOST: 'discord.gift',
|
|
||||||
RELEASE_CHANNEL: 'stable',
|
function protocolRelative(url) {
|
||||||
MARKETING_ENDPOINT: '//localhost:3001',
|
if (!url) return '';
|
||||||
BRAINTREE_KEY: 'production_5st77rrc_49pp2rp4phym7387',
|
return '//' + url.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
||||||
STRIPE_KEY: 'pk_live_CUQtlpQUF0vufWpnpUmQvcdi',
|
}
|
||||||
NETWORKING_ENDPOINT: '//localhost:3001',
|
|
||||||
RTC_LATENCY_ENDPOINT: '//localhost:3001',
|
async function loadGlobalEnv() {
|
||||||
ACTIVITY_APPLICATION_HOST: 'localhost:3001',
|
try {
|
||||||
PROJECT_ENV: 'production',
|
const res = await fetch("/api/v9/policies/instance/domains");
|
||||||
REMOTE_AUTH_ENDPOINT: '//remote-auth-gateway.discord.gg',
|
const data = await res.json();
|
||||||
SENTRY_TAGS: {"buildId":"9af39da","buildType":"normal"},
|
|
||||||
MIGRATION_SOURCE_ORIGIN: 'http://localhost:3001',
|
window.GLOBAL_ENV = {
|
||||||
MIGRATION_DESTINATION_ORIGIN: 'http://localhost:3001',
|
API_ENDPOINT: protocolRelative(data.apiEndpoint),
|
||||||
HTML_TIMESTAMP: Date.now(),
|
WEBAPP_ENDPOINT: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
ALGOLIA_KEY: 'aca0d7082e4e63af5ba5917d5e96bed0',
|
CDN_HOST: protocolRelative(data.cdn),
|
||||||
};</script><script nonce="">!function(){if(null!=window.WebSocket){var n=function(n){try{var e=localStorage.getItem(n);return null==e?null:JSON.parse(e)}catch(n){return null}},e=n("token"),o=n("gatewayURL");if(e&&o&&!window.__OVERLAY__){var r=null!=window.DiscordNative||null!=window.require?"etf":"json",t=o+"/?encoding="+r+"&v=9&compress=zlib-stream";console.log("[FAST CONNECT] "+t+", encoding: "+r+", version: 9");var a=new WebSocket(t);a.binaryType="arraybuffer";var s=Date.now(),i={open:!1,gateway:t,messages:[]};a.onopen=function(){console.log("[FAST CONNECT] connected in "+(Date.now()-s)+"ms"),i.open=!0},a.onclose=a.onerror=function(){window._ws=null},a.onmessage=function(n){i.messages.push(n)},window._ws={ws:a,state:i}}}}();</script><script src="/assets/7bee670797b9a4c1e09e.js" integrity="sha256-R+g4DcQ56i9OB2SbBsSuHr/4jGHnajy0rWydMTqeDqg= sha512-g0U47mQ+/ULG8F6M3OC2B4ows6GWx/au7hwNQLBS+GSHOoxBBs43Phl2KUkAUgePNnBLnK3cx2+PwhUSsUw6Bw=="></script><script src="/assets/5ca4d4e888e24c4376b2.js" integrity="sha256-Fg+CWdC+LsYyaNS+ZzQIUX6aJ/txrGIQ0V5Z98veBmg= sha512-DL32yCQDhhq8oOHHlyIZZX6APXo4RZ2RoxIs4fn41o70RQyGQFHE4g/BwnObYFEWip2B3mHWqp+v1WdOFK9rQw=="></script><script src="/assets/70fef35cbb2412cacff1.js" integrity="sha256-7U4LjIJUe5h0HGIvMUEUGCeQtmzugNJyBAe1TdPq1go= sha512-TanKHdCiIsqnoq3DtURaab2MV6j2/3O5zMVhRWLzEvhu8sa2E70gRfcmjz4OfeHCLZPr+7Z+o2tRnyxpbIR2Ng=="></script><script src="/assets/d0ccd2ec4ae7fd5186b0.js"></script>
|
ASSET_ENDPOINT: protocolRelative(data.cdn),
|
||||||
<script>
|
MEDIA_PROXY_ENDPOINT: protocolRelative(data.cdn),
|
||||||
if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/assets/test.js"); }
|
WIDGET_ENDPOINT: '//discord.com/widget',
|
||||||
</script>
|
INVITE_HOST: 'discord.gg',
|
||||||
<style>
|
GUILD_TEMPLATE_HOST: 'discord.new',
|
||||||
|
GIFT_CODE_HOST: 'discord.gift',
|
||||||
|
RELEASE_CHANNEL: 'stable',
|
||||||
|
MARKETING_ENDPOINT: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
BRAINTREE_KEY: 'production_5st77rrc_49pp2rp4phym7387',
|
||||||
|
STRIPE_KEY: 'pk_live_CUQtlpQUF0vufWpnpUmQvcdi',
|
||||||
|
NETWORKING_ENDPOINT: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
RTC_LATENCY_ENDPOINT: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
ACTIVITY_APPLICATION_HOST: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
PROJECT_ENV: 'production',
|
||||||
|
REMOTE_AUTH_ENDPOINT: '//remote-auth-gateway.discord.gg',
|
||||||
|
SENTRY_TAGS: { buildId: '9af39da', buildType: 'normal' },
|
||||||
|
MIGRATION_SOURCE_ORIGIN: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
MIGRATION_DESTINATION_ORIGIN: protocolRelative(data.apiEndpoint.replace(/\/api$/, '')),
|
||||||
|
HTML_TIMESTAMP: Date.now(),
|
||||||
|
ALGOLIA_KEY: 'aca0d7082e4e63af5ba5917d5e96bed0',
|
||||||
|
GATEWAY_URL: data.gateway
|
||||||
|
};
|
||||||
|
|
||||||
|
const scripts = [
|
||||||
|
'/assets/7bee670797b9a4c1e09e.js',
|
||||||
|
'/assets/5ca4d4e888e24c4376b2.js',
|
||||||
|
'/assets/70fef35cbb2412cacff1.js',
|
||||||
|
'/assets/d0ccd2ec4ae7fd5186b0.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
scripts.forEach(src => {
|
||||||
|
const s = document.createElement('script');
|
||||||
|
s.src = src;
|
||||||
|
s.defer = true;
|
||||||
|
document.body.appendChild(s);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load GLOBAL_ENV', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadGlobalEnv();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app-mount"></div>
|
||||||
|
|
||||||
|
<style>
|
||||||
[class^="qrCodeOverlay"] {
|
[class^="qrCodeOverlay"] {
|
||||||
all: unset;
|
all: unset;
|
||||||
background-image: url("/assets/pilkerton.png");
|
background-image: url("/assets/pilkerton.png");
|
||||||
@ -52,44 +93,13 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
[class*="qrCode-"][class*="spinner-"] { display: none; }
|
||||||
[class*="qrCode-"][class*="spinner-"] {
|
button[aria-label="Send a gift"], a[href="/store"] { display: none; }
|
||||||
display: none;
|
.platform-win .notice-3bPHh- { display: none; }
|
||||||
}
|
div[aria-controls="Discord Nitro-tab"],
|
||||||
|
div[aria-controls="Nitro Server Boost-tab"],
|
||||||
button[aria-label="Send a gift"] {
|
div[aria-controls="Library Inventory-tab"],
|
||||||
display: none;
|
div[aria-controls="Billing-tab"] { display: none; }
|
||||||
}
|
</style>
|
||||||
|
</body>
|
||||||
a[href="/store"] {
|
</html>
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.platform-win .notice-3bPHh- {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div[aria-controls="Discord Nitro-tab"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div[aria-controls="Nitro Server Boost-tab"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div[aria-controls="Nitro Server Boost-tab"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div[aria-controls="Library Inventory-tab"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div[aria-controls="Billing-tab"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</body></html>
|
|
||||||
|
|||||||
@ -103,7 +103,8 @@ export class SpacebarServer extends Server {
|
|||||||
app.use("/api", api); // allow unversioned requests
|
app.use("/api", api); // allow unversioned requests
|
||||||
|
|
||||||
app.use("/imageproxy/:hash/:size/:url", ImageProxy);
|
app.use("/imageproxy/:hash/:size/:url", ImageProxy);
|
||||||
// for the 2021 discord frontend, can be replaced with anything else, just respect the way this file is structured
|
|
||||||
|
// for the discord frontend, can be replaced with anything else, just respect the way this file is structured
|
||||||
app.use("/assets", express.static(path.join(PUBLIC_ASSETS_FOLDER, "client")));
|
app.use("/assets", express.static(path.join(PUBLIC_ASSETS_FOLDER, "client")));
|
||||||
|
|
||||||
app.get("/verify-email", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html")));
|
app.get("/verify-email", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html")));
|
||||||
@ -118,15 +119,15 @@ export class SpacebarServer extends Server {
|
|||||||
|
|
||||||
app.use("*_", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")));
|
app.use("*_", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")));
|
||||||
|
|
||||||
// current well-known location (new commit 22 nov 2025 from spacebar)
|
// current well-known location (new commit 22 nov 2025 from spacebar)
|
||||||
app.get("/.well-known/spacebar", (req,res)=>{
|
app.get("/.well-known/spacebar", (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
api: Config.get().api.endpointPublic
|
api: Config.get().api.endpointPublic,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// new well-known location
|
// new well-known location
|
||||||
app.get("/.well-known/spacebar/client", (req,res)=>{
|
app.get("/.well-known/spacebar/client", (req, res) => {
|
||||||
let erlpackSupported = false;
|
let erlpackSupported = false;
|
||||||
try {
|
try {
|
||||||
require("@yukikaze-bot/erlpack");
|
require("@yukikaze-bot/erlpack");
|
||||||
@ -140,17 +141,17 @@ export class SpacebarServer extends Server {
|
|||||||
baseUrl: Config.get().api.endpointPublic?.split("/api")[0] || "", // TODO: migrate database values to not include /api/v9
|
baseUrl: Config.get().api.endpointPublic?.split("/api")[0] || "", // TODO: migrate database values to not include /api/v9
|
||||||
apiVersions: {
|
apiVersions: {
|
||||||
default: Config.get().api.defaultVersion,
|
default: Config.get().api.defaultVersion,
|
||||||
active: Config.get().api.activeVersions
|
active: Config.get().api.activeVersions,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
cdn: {
|
cdn: {
|
||||||
baseUrl: Config.get().cdn.endpointPublic
|
baseUrl: Config.get().cdn.endpointPublic,
|
||||||
},
|
},
|
||||||
gateway: {
|
gateway: {
|
||||||
baseUrl: Config.get().gateway.endpointPublic,
|
baseUrl: Config.get().gateway.endpointPublic,
|
||||||
encoding: [...(erlpackSupported ? ["etf"] : []), "json"],
|
encoding: [...(erlpackSupported ? ["etf"] : []), "json"],
|
||||||
compression: ["zstd-stream", "zlib-stream", null],
|
compression: ["zstd-stream", "zlib-stream", null],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user