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

非云引擎环境 API url 未设置问题 #166

Open
huaiyin0416 opened this issue Jan 22, 2018 · 11 comments
Open

非云引擎环境 API url 未设置问题 #166

huaiyin0416 opened this issue Jan 22, 2018 · 11 comments

Comments

@huaiyin0416
Copy link

Fatal error: Uncaught exception 'RuntimeException' with message 'CURL connection (/1.1/classes/zyb1?where=%7B%22objectId%22%3A%225a6587281b69e60066f7c035%22%7D&skip=0&limit=1) error: 3 malformed' in D:\xue\2\leancloud\src\LeanCloud\Client.php:409 Stack trace: #0 D:\xue\2\leancloud\src\LeanCloud\Client.php(439): LeanCloud\Client::request('GET', '/classes/zyb1', Array, NULL, Array, NULL) #1 D:\xue\2\leancloud\src\LeanCloud\Query.php(741): LeanCloud\Client::get('/classes/zyb1', Array) #2 D:\xue\2\leancloud\src\LeanCloud\Query.php(714): LeanCloud\Query->find(0, 1) #3 D:\xue\2\leancloud\src\LeanCloud\Query.php(705): LeanCloud\Query->first() #4 D:\xue\2\index.php(12): LeanCloud\Query->get('5a6587281b69e60...') #5 {main} thrown in D:\xue\2\leancloud\src\LeanCloud\Client.php on line 409
请问装好 运行后提示这个是什么原因呢?

@juvenn
Copy link
Member

juvenn commented Jan 22, 2018

这是API 网关未设置的问题。我们建议你使用云引擎命令行来开发和部署应用,这样会自动设置 API 网关。

如果坚持要独立运行的话,请在 apache 配置文件中设置:

<VirtualHost *:80>
  SetEnv LEANCLOUD_API_SERVER https://{appid 前 8 位}.api.lncld.net
  ...
</VirtualHost>

@juvenn juvenn changed the title Fatal error: Uncaught exception 'RuntimeException' with message 'CURL connection (/1.1/classes/zyb1?where=%7B%22objectId%22%3A%225a6587281b69e60066f7c035%22%7D&skip=0&limit=1) error: 3 <url> malformed' in D:\xue\2\leancloud\src\LeanCloud\Client.php:409 Stack trace: #0 D:\xue\2\leancloud\src\LeanCloud\Client.php(439): LeanCloud\Client::request('GET', '/classes/zyb1', Array, NULL, Array, NULL) #1 D:\xue\2\leancloud\src\LeanCloud\Query.php(741): LeanCloud\Client::get('/classes/zyb1', Array) #2 D:\xue\2\leancloud\src\LeanCloud\Query.php(714): LeanCloud\Query->find(0, 1) #3 D:\xue\2\leancloud\src\LeanCloud\Query.php(705): LeanCloud\Query->first() #4 D:\xue\2\index.php(12): LeanCloud\Query->get('5a6587281b69e60...') #5 {main} thrown in D:\xue\2\leancloud\src\LeanCloud\Client.php on line 409 非云引擎环境 API url 未设置问题 Jan 22, 2018
@huaiyin0416
Copy link
Author

huaiyin0416 commented Jan 22, 2018

image

添加之后还是这样子 麻烦帮我看看是什么问题 谢谢

@huaiyin0416
Copy link
Author

image

@juvenn
Copy link
Member

juvenn commented Jan 22, 2018

注意看这个 url ,你设置环境变量的时候多了一个 =

另外,请不要在公共场合粘贴 master key ,这会有安全风险。请删除代码截屏,并进入 leancloud 控制台重置 master key 。

@huaiyin0416
Copy link
Author

好的 谢谢

@huaiyin0416
Copy link
Author

@juvenn 你好 我这里环境变量没有加 = 为什么错误提示是多了这个呢 没有修改过LeanCloud里面的文件

@juvenn
Copy link
Member

juvenn commented Jan 22, 2018

可能是你的 apache 配置格式不对,比如你的 ServerAlias 没有值?另外也建议你将 SetEnv 置于 ServerAlias 的下面,并确认有正确的换行。

@huaiyin0416
Copy link
Author

image
@juvenn 你好 我这样子配置了 还是那个报错 你那边有木有配置好的 可以正常使用的呢,可以发我一份研究嘛

@juvenn
Copy link
Member

juvenn commented Jan 23, 2018

抱歉,是我搞错了,中间应该没有等号:

SetEnv LEANCLOUD_API_SERVER https://{appid 前 8 位}.api.lncld.net

http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv

@huaiyin0416
Copy link
Author

@juvenn 可以了 谢谢 好感动 好腻害

@juvenn
Copy link
Member

juvenn commented Jan 26, 2018

这里再总结一下。

如果是 apache 服务器,请在配置中设置:

<VirtualHost *:80>
  ...
  SetEnv LEANCLOUD_API_SERVER https://{appid 前 8 位}.api.lncld.net
  ...
</VirtualHost>

如果是 nginx ,请设置:

location / {
...
   fastcgi_param   LEANCLOUD_API_SERVER  https://{appid 前 8 位}.api.lncld.net;
...
}

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

No branches or pull requests

2 participants