Fix Telegram webhook route: Move before generic OPTIONS route
This commit is contained in:
@@ -52,11 +52,6 @@ $app->add(function (Request $request, $handler) {
|
||||
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
||||
});
|
||||
|
||||
// Handle OPTIONS request
|
||||
$app->options('/{routes:.+}', function (Request $request, Response $response) {
|
||||
return $response;
|
||||
});
|
||||
|
||||
// Add error middleware
|
||||
$app->addErrorMiddleware(true, true, true);
|
||||
|
||||
@@ -215,10 +210,17 @@ $app->get('/fast/mandiri/{tanggal}', [$fastController, 'mandiri']);
|
||||
$app->post('/site/verify_bri', [$siteController, 'verifyBri']);
|
||||
$app->post('/site/approve/{id_trx}', [$siteController, 'approve']);
|
||||
|
||||
// Telegram Bot Routes
|
||||
// Telegram Bot Routes (diletakkan sebelum route generic untuk menghindari konflik)
|
||||
$telegramBotController = new \App\Controllers\TelegramBotController();
|
||||
$app->post('/telegram/webhook', [$telegramBotController, 'webhook']);
|
||||
// Note: OPTIONS request sudah ditangani oleh route generic di line 56
|
||||
$app->options('/telegram/webhook', function (Request $request, Response $response) {
|
||||
return $response->withStatus(200);
|
||||
});
|
||||
|
||||
// Handle OPTIONS request untuk route lainnya (harus setelah route spesifik)
|
||||
$app->options('/{routes:.+}', function (Request $request, Response $response) {
|
||||
return $response;
|
||||
});
|
||||
|
||||
// Run app
|
||||
$app->run();
|
||||
|
||||
Reference in New Issue
Block a user