BODY_SIZE_LIMIT erstellt

This commit is contained in:
titver968
2025-04-25 08:14:39 +02:00
parent 7cf57dde9b
commit ac865ddd37
7 changed files with 30 additions and 9 deletions

View File

@@ -15,5 +15,5 @@ FROM node:23.11-alpine3.20
COPY --from=build /app .
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["sh", "-c", "ORIGIN=https://praktikum.innovation-hub-niedersachsen.de node build/index.js"]
CMD ["sh", "-c", "BODY_SIZE_LIMIT=500M ORIGIN=https://praktikum.innovation-hub-niedersachsen.de node build/index.js"]

Binary file not shown.

16
server.js Normal file
View File

@@ -0,0 +1,16 @@
import { createServer } from 'http';
import { handler } from './build/index.js';
const server = createServer((req, res) => {
if (req.headers['content-length'] > 50 * 1024 * 1024) { // 50 MB
res.statusCode = 413; // Payload Too Large
res.end('Payload Too Large');
return;
}
handler(req, res);
});
server.listen(3000, () => {
console.log('Server läuft auf Port 3000');
});

11
src/hooks.server.ts Normal file
View File

@@ -0,0 +1,11 @@
import { sequence } from '@sveltejs/kit/hooks';
import { json } from '@sveltejs/kit';
export const handle = sequence(
async ({ event, resolve }) => {
return resolve(event, {
// Erhöhe das Limit hier (z.B. auf 1 GB = 20 * 1024 * 1024)
maxBodySize: 1024 * 1024 * 1024
});
}
);

View File

@@ -11,14 +11,8 @@ const config = {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter(),
},
vite: {
server: {
maxPayload: 2048 * 1024 * 1024 // 2 GB, adjust as needed
adapter: adapter()
}
}
};
export default config;