@kozojs/cli 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +3 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1496,11 +1496,12 @@ ${auth ? "JWT_SECRET=change-me-to-a-random-secret-at-least-32-chars\n" : ""}`;
|
|
|
1496
1496
|
` : "";
|
|
1497
1497
|
const servicesSetup = "\nconst services = {};\n";
|
|
1498
1498
|
const authMiddleware = auth ? `
|
|
1499
|
-
// JWT protects all /api/* routes except
|
|
1499
|
+
// JWT protects all /api/* routes except public ones
|
|
1500
1500
|
const JWT_SECRET = process.env.JWT_SECRET || 'change-me';
|
|
1501
1501
|
const _jwt = authenticateJWT(JWT_SECRET, { prefix: '' });
|
|
1502
|
+
const publicPaths = ['/api/auth/', '/api/health', '/api/stats'];
|
|
1502
1503
|
app.getApp().use('/api/*', (c, next) => {
|
|
1503
|
-
if (c.req.path.startsWith(
|
|
1504
|
+
if (publicPaths.some(p => c.req.path.startsWith(p))) return next();
|
|
1504
1505
|
return _jwt(c, next);
|
|
1505
1506
|
});
|
|
1506
1507
|
` : "";
|