fix(web-api): CORS preflight OPTIONS до CorsMiddleware - #637
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Router обрабатывает OPTIONS на известных storefront-путях через middleware без вызова handler. CorsMiddleware возвращает Response 200 вместо exit. Closes #634
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Браузерный CORS preflight (
OPTIONS) к Web API получал 405Method not allowed: FastRoute отдавалMETHOD_NOT_ALLOWEDдо запуска group middleware, иCorsMiddlewareне успевал ответить.Теперь
Router::dispatch()наOPTIONSдля известных storefront-путей (/api/v1/*) прогоняет только middleware найденного маршрута. Handler не вызывается — preflight не триггерит POST/GET side effects.CorsMiddlewareвозвращаетResponse200 вместоexit, чтобы Router и PHPUnit могли обработать ответ.Closes #634
Тип изменений
Связанные Issues
Closes #634
Как это было протестировано?
Добавлены
HeadlessStorefrontCorsRouterTest: OPTIONS на/api/v1/health, POST-only/api/v1/cart/add, неизвестный path → 404, handler не вызывается без CorsMiddleware.composer ci:php)Конфигурация тестирования:
Чеклист
Дополнительные заметки
Кастомные роуты в
ms3.routes.d/webбезCorsMiddlewareпо-прежнему получат 405 на OPTIONS (handler не выполняется). Для headless-витрины аддон должен вешать тот же CORS stack, что иweb.php.