Configuration
Newgate follows a "configuration by code" philosophy. Most configuration
happens when setting up the App instance or via middleware.
CORS Configuration
Cross-Origin Resource Sharing (CORS) can be configured using app.cors().
app.cors({
origin: ['https://trusted.com'],
methods: ['GET', 'POST'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true
});
Environment Variables
We recommend using dotenv for managing environment-specific configuration.
npm install dotenv
// server.js
import 'dotenv/config';
import App from 'newgatejs';
const app = new App();
const PORT = process.env.PORT || 3000;
app.listen(PORT);
Parser Limits
You can configure limits for the form-data parser to protect against DoS attacks.
// Limits are applied internally by the parser middleware
// Currently, these are set to safe defaults:
// - File Size: 10MB
// - Total Memory: 50MB
Last updated: 12/11/2025
Edit on GitHub