-
Notifications
You must be signed in to change notification settings - Fork 9
Fix splash page styling issues #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Moved inline CSS to external stylesheet to comply with CSP - Added black background to logo area for visibility of white MCP logo - Updated specification link to point to dated version (2025-06-18) - Changed "MCP Everything Server" to "MCP Example Server" - Added route to serve styles.css file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
app.get("/styles.css", (req, res) => { | ||
const cssPath = path.join(__dirname, "static", "styles.css"); | ||
res.setHeader('Content-Type', 'text/css'); | ||
res.sendFile(cssPath); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a file system access
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To address the missing rate limiting in the /styles.css
route handler at line 170, we should apply a rate-limiting middleware to restrict how frequently a client can request this resource. The simplest way is to use the popular express-rate-limit
package, which is well maintained and purpose-built for this scenario. We'll need to:
- Import
express-rate-limit
- Create a rate limiter instance, e.g., 100 requests per 15 minutes per IP (similar to the background example).
- Apply the rate limiter as middleware for the
/styles.css
route (at line 170) before the handler.
Changes to make:
- Add a new import for
express-rate-limit
at the top. - Define a rate limiting middleware before route handlers.
- Apply it directly to the
/styles.css
route.
No other changes are needed, and we should not interfere with any existing functionality for other routes.
-
Copy modified line R6 -
Copy modified lines R19-R23 -
Copy modified line R176
@@ -3,6 +3,7 @@ | ||
import cors from "cors"; | ||
import express from "express"; | ||
import path from "path"; | ||
import rateLimit from "express-rate-limit"; | ||
import { fileURLToPath } from "url"; | ||
import { EverythingAuthProvider } from "./auth/provider.js"; | ||
import { BASE_URI, PORT } from "./config.js"; | ||
@@ -15,6 +16,11 @@ | ||
|
||
const app = express(); | ||
|
||
// Set up rate limiter for static assets: max 100 requests per 15 minutes per IP | ||
const staticAssetLimiter = rateLimit({ | ||
windowMs: 15 * 60 * 1000, // 15 minutes | ||
max: 100, // limit each IP to 100 requests per windowMs | ||
}); | ||
// Get the directory of the current module | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
@@ -167,7 +173,7 @@ | ||
res.sendFile(logoPath); | ||
}); | ||
|
||
app.get("/styles.css", (req, res) => { | ||
app.get("/styles.css", staticAssetLimiter, (req, res) => { | ||
const cssPath = path.join(__dirname, "static", "styles.css"); | ||
res.setHeader('Content-Type', 'text/css'); | ||
res.sendFile(cssPath); |
-
Copy modified lines R35-R36
@@ -32,7 +32,8 @@ | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.4.7", | ||
"express": "^4.21.2", | ||
"raw-body": "^3.0.0" | ||
"raw-body": "^3.0.0", | ||
"express-rate-limit": "^8.0.1" | ||
}, | ||
"overrides": { | ||
"@types/express": "^5.0.0", |
Package | Version | Security advisories |
express-rate-limit (npm) | 8.0.1 | None |
Summary
Changes
index.html
to newstyles.css
fileindex.ts
to serve the CSS file with proper content-type/specification/2025-06-18
Test plan
npm run build
npm start
🤖 Generated with Claude Code