Skip to content

Commit 23d7507

Browse files
committed
Fix "405 Method Not Allowed" bug caused by routing.
1 parent 7b95c68 commit 23d7507

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@
156156
$router->map('GET', '/{page:(?:.|/)*}', HttpToHttpsController::class)->setScheme('http');
157157
}
158158

159+
/*/ To prevent "405 Method Not Allowed" from the Router we only map `/*` to
160+
* OPTIONS when OPTIONS are actually requested.
161+
/*/
162+
if ($request->getMethod() === 'OPTIONS') {
163+
$router->map('OPTIONS', '/{path:.*}', CorsController::class);
164+
}
165+
159166
$router->map('GET', '/', HelloWorldController::class);
160167

161168
// @FIXME: CORS handling, slash-adding (and possibly others?) should be added as middleware instead of "catchall" URLs map
@@ -171,8 +178,6 @@
171178

172179
$router->map('GET', '/login', AddSlashToPathController::class);
173180
$router->map('GET', '/profile', AddSlashToPathController::class);
174-
175-
$router->map('OPTIONS', '/{path:.*}', CorsController::class);
176181
$router->map('GET', '/.well-known/openid-configuration', OpenidController::class);
177182
$router->map('GET', '/jwks', JwksController::class);
178183
$router->map('GET', '/login/', LoginPageController::class);

0 commit comments

Comments
 (0)