Add authorization header to versions (not in use yet)

This commit is contained in:
Lncvrt committed 2026-10-02 10:47:59 -07:00
1 parent c205c1bdaf
commit a433f57a58
2 files changed
+10 -4

No files matched your search

+5 -4
View File
@@ -179,11 +179,11 @@ setInterval(async () => {
app.ws('/ws', { app.ws('/ws', {
maxPayloadLength: 10 * 1024 * 1024, maxPayloadLength: 10 * 1024 * 1024,
open (ws) { open(ws) {
clients.add(ws) clients.add(ws)
// console.log(ws.id, 'connected') // console.log(ws.id, 'connected')
}, },
async message (ws, message: any) { async message(ws, message: any) {
console.log('received:', message, 'from', ws.id) console.log('received:', message, 'from', ws.id)
if (message == 'ping') ws.send('ping') if (message == 'ping') ws.send('ping')
if (message.type) { if (message.type) {
@@ -903,7 +903,7 @@ app.ws('/ws', {
} }
} }
}, },
async close (ws) { async close(ws) {
clients.forEach(client => { clients.forEach(client => {
if (client.id === ws.id) clients.delete(client) if (client.id === ws.id) clients.delete(client)
}) })
@@ -986,7 +986,8 @@ app.get('/launcher/versions', context => launcherVersionsHandler(context), {
hide: true hide: true
}) })
), ),
clientplatform: t.Optional(t.String()) clientplatform: t.Optional(t.String()),
authorization: t.Optional(t.String())
}) })
}) })
app.get('/launcher/latest', launcherLatestHandler, { app.get('/launcher/latest', launcherLatestHandler, {
+5
View File
@@ -9,6 +9,11 @@ export const handler = async (context: Context) => {
return jsonResponse({ error: 'Failed to connect to database' }, 500) return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult const { connection, db } = dbResult
const authorization =
context.headers.authorization?.trim() == '' ||
context.headers.authorization == null
? null
: context.headers.authorization
const clientplatform = context.headers.clientplatform const clientplatform = context.headers.clientplatform
const platform = clientplatform?.split('-')[0] const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1] const arch = clientplatform?.split('-')[1]