1

我正在使用 Docker for Windows 来托管 Laravel 实例

我在 Docker 上运行 Laravel(在 http://localhost:8080 上运行)。我在我的计算机上的http://api.mywebsite.test上有一个 API 服务- 而不是在 docker 中。

我正在尝试从 docker 网站 CURL REST API。它没有响应,我不知道为什么。

当我从 bash 卷曲时,它可以正常工作。例子 :

curl --location --request POST 'http://oauth.mysite.test/server.php?grant_type=client_credentials' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials'

在我的浏览器中它也可以工作。

但是从我的 php 脚本中,例如file_get_contents返回一个错误:

ErrorException: file_get_contents(http://oauth.mysite.test/server.php): Failed to open stream: HTTP request failed!

使用 Guzzle 只会永远循环,只会让我的 Docker 崩溃,然后我需要重新启动。

4

0 回答 0