Skip to content

Commit ae1b194

Browse files
fix: disable pod creation in single-user mode
Returns 403 when POST /.pods is called with --single-user enabled. Closes JavaScriptSolidServer#257
1 parent 14b86a4 commit ae1b194

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/server.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,22 @@ export function createServer(options = {}) {
472472

473473
// Pod creation endpoint with rate limiting
474474
// Limit: 1 pod per IP per day to prevent resource exhaustion and namespace squatting
475-
fastify.post('/.pods', {
476-
config: {
477-
rateLimit: {
478-
max: 1,
479-
timeWindow: '1 day',
480-
keyGenerator: (request) => request.ip
475+
// Disabled in single-user mode
476+
if (singleUser) {
477+
fastify.post('/.pods', async (request, reply) => {
478+
return reply.code(403).send({ error: 'Pod creation disabled in single-user mode' });
479+
});
480+
} else {
481+
fastify.post('/.pods', {
482+
config: {
483+
rateLimit: {
484+
max: 1,
485+
timeWindow: '1 day',
486+
keyGenerator: (request) => request.ip
487+
}
481488
}
482-
}
483-
}, handleCreatePod);
489+
}, handleCreatePod);
490+
}
484491

485492
// Mashlib CDN mode: redirect chunk requests to CDN
486493
if (mashlibEnabled && mashlibCdn) {

0 commit comments

Comments
 (0)