Skip to content

Commit bbcfe0d

Browse files
committed
Provide extra info when pushing tasks to non-https URL
1 parent b0fdb29 commit bbcfe0d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Config.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public static function getHandler($handler): string
5151
));
5252
}
5353

54+
// When the application is running behind a proxy and the TrustedProxy middleware has not been set up yet,
55+
// an error like [HttpRequest.url must start with 'https'] could be thrown. Since the handler URL must
56+
// always be https, we will provide a little extra information on how to fix this.
57+
if ($parse['scheme'] !== 'https') {
58+
throw new Exception(sprintf(
59+
'Unable to push task to Cloud Tasks because the hander URL is not https. Google Cloud Tasks ' .
60+
'will only call safe (https) URLs. If you are running Laravel behind a proxy (e.g. Ngrok, Expose), make sure it is ' .
61+
'as a trusted proxy. To quickly fix this, add the following to the [app/Http/Middleware/TrustProxies] middleware: ' .
62+
'protected $proxies = \'*\';'
63+
));
64+
}
65+
5466
// Versions 1.x and 2.x required the full path (e.g. my-app.com/handle-task). In 3.x and beyond
5567
// it is no longer necessary to also include the path and simply setting the handler
5668
// URL is enough. If someone upgrades and forgets we will warn them here.

0 commit comments

Comments
 (0)