我在 Laravel 5.0 框架 (PHP 5.6/MySql) 中开发了一个 api,并托管在 Apache 2.4.7 (Ubuntu) 中,使用 GoDaddy 作为 CA 提供的 SSL 证书。所有API都可以访问,因为它在http://。但是在添加 SSL 证书后,没有任何移动应用程序(Android 和 iOS)可以访问这些 API,因为它给出了一个空响应。
但是在 postman 和浏览器中,我得到的响应非常棒。响应在 Json 中。移动开发人员使用的解析库是异步的。在进入 https://之前,我们必须在客户端或服务器端执行任何步骤吗?
最佳答案
很有可能,您的代码可能会抛出以下错误:
XMLHttpRequest cannot load https://xxx. No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'http://yyy' is
therefore not allowed access. The response had HTTP status code 405.
您需要更新您的 API 以允许来自任何来源的请求。 Laravel CORS library如果是这种情况,可以提供帮助。
关于php - 在 Apache 服务器中托管的 Laravel 框架中开发的 API 在从 Android 和 iOS 移动应用程序请求时没有得到任何响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37809981/