Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for missing scheme on ADMIN_APP_URL #1159

Closed

Conversation

antonioribeiro
Copy link
Member

Description

If we set the application URLs as

APP_URL=https://domain.com
ADMIN_APP_URL=admin.domain.com

Twill Exception handler will end abnormally the application if an exception occurs:

[2021-09-17 18:15:42] dev.ERROR: Uncaught ErrorException: Undefined array key "host" in /sites/domain.com/vendor/area17/twill/src/Exceptions/Handler.php:40
Stack trace:
#0 /sites/domain.com/vendor/area17/twill/src/Exceptions/Handler.php(40): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /sites/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(569): A17\Twill\Exceptions\Handler->getHttpExceptionView()
#2 /sites/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(478): Illuminate\Foundation\Exceptions\Handler->renderHttpException()
#3 /sites/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(356): Illuminate\Foundation\Exceptions\Handler->prepareResponse()
#4 /sites/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(119): Illuminate\Foundation\Exceptions\Handler->render()
#5 /sites/domain.com/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(96): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse()
#6 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
#7 {main}
  thrown {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught ErrorException: Undefined array key \"host\" in /sites/domain.com/vendor/area17/twill

For this to work, people need to remember to add the scheme to the Twill's admin URL too:

APP_URL=https://domain.com
ADMIN_APP_URL=https://admin.domain.com

This is happening because parse_url() needs the scheme to correctly parse the URL, so this is good as it parses and finds the host:

parse_url('https://admin.domain.com');

[
     "scheme" => "https",
     "host" => "admin.domain.com",
]

But without the scheme we get:

parse_url('admin.domain.com');

[
     "path" => "admin.domain.com",
]

This PR a quick fix for it, but this problem is actually deeper and needs us to fix it for good on 3.0.

@pboivin
Copy link
Contributor

pboivin commented Oct 22, 2021

Thanks @antonioribeiro! Closing in favor of #1213 which removes the parse_url() call

@pboivin pboivin closed this Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants