File tree 3 files changed +17
-5
lines changed
3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,18 @@ public static function getHandler($handler): string
51
51
));
52
52
}
53
53
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
+
54
66
// Versions 1.x and 2.x required the full path (e.g. my-app.com/handle-task). In 3.x and beyond
55
67
// it is no longer necessary to also include the path and simply setting the handler
56
68
// URL is enough. If someone upgrades and forgets we will warn them here.
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function a_http_request_with_the_handler_url_is_made()
42
42
43
43
// Assert
44
44
CloudTasksApi::assertTaskCreated (function (Task $ task ): bool {
45
- return $ task ->getHttpRequest ()->getUrl () === 'http ://docker.for.mac.localhost:8080/handle-task ' ;
45
+ return $ task ->getHttpRequest ()->getUrl () === 'https ://docker.for.mac.localhost:8080/handle-task ' ;
46
46
});
47
47
}
48
48
@@ -69,15 +69,15 @@ public function it_posts_to_the_handler()
69
69
public function it_posts_to_the_correct_handler_url ()
70
70
{
71
71
// Arrange
72
- $ this ->setConfigValue ('handler ' , 'http ://docker.for.mac.localhost:8081 ' );
72
+ $ this ->setConfigValue ('handler ' , 'https ://docker.for.mac.localhost:8081 ' );
73
73
CloudTasksApi::fake ();
74
74
75
75
// Act
76
76
$ this ->dispatch (new SimpleJob ());
77
77
78
78
// Assert
79
79
CloudTasksApi::assertTaskCreated (function (Task $ task ): bool {
80
- return $ task ->getHttpRequest ()->getUrl () === 'http ://docker.for.mac.localhost:8081/handle-task ' ;
80
+ return $ task ->getHttpRequest ()->getUrl () === 'https ://docker.for.mac.localhost:8081/handle-task ' ;
81
81
});
82
82
}
83
83
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ protected function getEnvironmentSetUp($app)
101
101
'queue ' => 'barbequeue ' ,
102
102
'project ' => 'my-test-project ' ,
103
103
'location ' => 'europe-west6 ' ,
104
- 'handler ' => env ('CLOUD_TASKS_HANDLER ' , 'http ://docker.for.mac.localhost:8080 ' ),
104
+ 'handler ' => env ('CLOUD_TASKS_HANDLER ' , 'https ://docker.for.mac.localhost:8080 ' ),
105
105
'service_account_email ' => 'info@stackkit.io ' ,
106
106
]);
107
107
$ app ['config ' ]->set ('queue.failed.driver ' , 'database-uuids ' );
@@ -216,7 +216,7 @@ protected function addIdTokenToHeader(?Closure $closure = null): void
216
216
{
217
217
$ base = [
218
218
'iss ' => 'https://accounts.google.com ' ,
219
- 'aud ' => 'http ://docker.for.mac.localhost:8080 ' ,
219
+ 'aud ' => 'https ://docker.for.mac.localhost:8080 ' ,
220
220
'exp ' => time () + 10 ,
221
221
];
222
222
You can’t perform that action at this time.
0 commit comments