Skip to content

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

Open

Description

@huaiyin0416

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
请问装好 运行后提示这个是什么原因呢?

Activity

  1. juvenn commented on Jan 22, 2018

    @juvenn
    Contributor

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

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

    <VirtualHost *:80>
      SetEnv LEANCLOUD_API_SERVER https://{appid 前 8 位}.api.lncld.net
      ...
    </VirtualHost>
    
  2. 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 未设置问题[/+] on Jan 22, 2018
  3. huaiyin0416 commented on Jan 22, 2018

    @huaiyin0416
    Author

    image

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

  4. huaiyin0416 commented on Jan 22, 2018

    @huaiyin0416
    Author

    image

  5. juvenn commented on Jan 22, 2018

    @juvenn
    Contributor

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

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

  6. huaiyin0416 commented on Jan 22, 2018

    @huaiyin0416
    Author

    好的 谢谢

  7. huaiyin0416 commented on Jan 22, 2018

    @huaiyin0416
    Author

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

  8. juvenn commented on Jan 22, 2018

    @juvenn
    Contributor

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

  9. huaiyin0416 commented on Jan 23, 2018

    @huaiyin0416
    Author

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

  10. juvenn commented on Jan 23, 2018

    @juvenn
    Contributor

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

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

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

  11. huaiyin0416 commented on Jan 23, 2018

    @huaiyin0416
    Author

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

  12. juvenn commented on Jan 26, 2018

    @juvenn
    Contributor

    这里再总结一下。

    如果是 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions