mirror of
https://github.com/sune-org/ORP.git
synced 2026-01-14 00:27:59 +00:00
Fix: Require UID, remove anon fallback
This commit is contained in:
5
index.js
5
index.js
@@ -33,8 +33,9 @@ export default {
|
|||||||
const isWs = req.headers.get('Upgrade') === 'websocket';
|
const isWs = req.headers.get('Upgrade') === 'websocket';
|
||||||
if (!isGet && !isWs) return withCORS(new Response('method not allowed', { status: 405 }));
|
if (!isGet && !isWs) return withCORS(new Response('method not allowed', { status: 405 }));
|
||||||
|
|
||||||
const rawUid = url.searchParams.get('uid') || 'anon';
|
const uid = (url.searchParams.get('uid') || '').slice(0, 64).replace(/[^a-zA-Z0-9_-]/g, '');
|
||||||
const uid = String(rawUid).slice(0, 64).replace(/[^a-zA-Z0-9_-]/g, '') || 'anon';
|
if (!uid) return withCORS(new Response('uid is required', { status: 400 }));
|
||||||
|
|
||||||
const id = env.MY_DURABLE_OBJECT.idFromName(uid);
|
const id = env.MY_DURABLE_OBJECT.idFromName(uid);
|
||||||
const stub = env.MY_DURABLE_OBJECT.get(id);
|
const stub = env.MY_DURABLE_OBJECT.get(id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user