Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Maintenance mode --render option vs. json requests #2644

Open
aedart opened this issue Jun 18, 2021 · 0 comments
Open

Maintenance mode --render option vs. json requests #2644

aedart opened this issue Jun 18, 2021 · 0 comments

Comments

@aedart
Copy link

aedart commented Jun 18, 2021

The "new" --render argument for artisan down command does it's job well, by rendering whatever template has been requested. Sadly, when using this option it appears that API requests (requests that have Accept: application/json header set) are not handled correctly.

The framework usually deals with this automatically, when not using the --render option. But, when running composer install / update in the background, some requests might actually lead to an "Internal Server Error", because parts of the framework / vendor has yet to be installed by composer. So, the new pre-rendering of view makes a lot of sense. But it would be really nice if pre-rendering / maintenance mode could somehow take API requests into account.

Possible Solution A

The generated storage/framework/maintenance.php could check for Accept: application/json headers (or variants hereof) and ensure NOT to output html, if such is the case.

Possible Solution B

Add a --resolve-via argument to the artisan down that accepts a php file path. This file could then be used instead of the maintenance.php file, allowing developer to resolve maintenance mode however they wish.
Note: this does differ from the --render in that pre-rendered blade templates or php files do not have access to the http headers of the current request (at least not according to my knowledge / experiments).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant