Archnemix commited on
Commit
bb62b5b
·
verified ·
1 Parent(s): cf41c3f

Update src/index.js

Browse files
Files changed (1) hide show
  1. src/index.js +10 -7
src/index.js CHANGED
@@ -18,16 +18,19 @@ for (const key of REQUIRED_ENV) {
18
 
19
  const app = express()
20
 
21
- // Raw body only for /interactions — needed for Ed25519 signature verification
22
- app.use('/interactions', express.raw({ type: 'application/json' }))
23
-
24
- // JSON body for all other routes
25
- app.use(express.json())
 
 
 
 
26
 
27
  app.use('/', router)
28
 
29
  const PORT = process.env.PORT || 7860
30
-
31
  app.listen(PORT, () => {
32
  console.log(`[startup] gateway-services running on port ${PORT} — ${new Date().toISOString()}`)
33
- })
 
18
 
19
  const app = express()
20
 
21
+ // Raw body for /interactions — must come first, before any JSON middleware.
22
+ // type: '*/*' captures whatever Content-Type Discord sends.
23
+ app.use('/interactions', express.raw({ type: '*/*' }))
24
+
25
+ // JSON body for every other route — skip /interactions so the raw Buffer is preserved.
26
+ app.use((req, res, next) => {
27
+ if (req.path === '/interactions') return next()
28
+ express.json()(req, res, next)
29
+ })
30
 
31
  app.use('/', router)
32
 
33
  const PORT = process.env.PORT || 7860
 
34
  app.listen(PORT, () => {
35
  console.log(`[startup] gateway-services running on port ${PORT} — ${new Date().toISOString()}`)
36
+ })