completionId: cgen-94b0611ce8b4483ab9317301fa181f28
cgen-94b0611ce8b4483ab9317301fa181f28
This commit is contained in:
parent
a8a517b318
commit
ec7187ecc4
1 changed files with 10 additions and 10 deletions
|
|
@ -73,8 +73,18 @@ const handleDiscordInteractions = (
|
|||
export function createServer() {
|
||||
const app = express();
|
||||
|
||||
// Discord endpoint MUST be defined BEFORE any body parsing middleware
|
||||
// and needs raw body for signature verification
|
||||
app.post(
|
||||
"/api/discord/interactions",
|
||||
express.raw({ type: "application/json" }),
|
||||
handleDiscordInteractions,
|
||||
);
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Allow Discord to embed the activity in iframes
|
||||
app.use((req, res, next) => {
|
||||
|
|
@ -93,16 +103,6 @@ export function createServer() {
|
|||
next();
|
||||
});
|
||||
|
||||
// Discord endpoint needs raw body for signature verification
|
||||
app.post(
|
||||
"/api/discord/interactions",
|
||||
express.raw({ type: "application/json" }),
|
||||
handleDiscordInteractions,
|
||||
);
|
||||
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Example API routes
|
||||
app.get("/api/ping", (_req, res) => {
|
||||
const ping = process.env.PING_MESSAGE ?? "ping";
|
||||
|
|
|
|||
Loading…
Reference in a new issue