且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解析服务器云代码功能“无法POST”

更新时间:2023-02-22 21:33:40

答案是,与Parses托管解决方案不同,API版本路径不是由parse-server



托管的东西(如果您主机解析为eg:/ parse) ,那么这是函数API可用的相对URL。所以只需从路径中删除/ 1 /。

同样的curl命令适用于此URL



http:// localhost:1337 / parse / functions / hello



例如:

  curl -X POST \ 
-HX-Parse-Application-Id:myAppId \\
-HX-Parse-REST-API-Key:myRESTKey\
-HContent-Type:application / json\
-d'{}'\\ \\
http:// localhost:1337 / parse / functions / hello


Most parts of my migration to open source parse-server are successful, with my data correctly stored, accessible.

I am however having problems with cloud code, specifically with running simple curl tests.

The initial parse-server installation includes a sample main.js file that contains a hello world function

My own parse installation is hosted at '/parse' so URLs use this as the root

The following is a simple request test

 curl -X POST \   
 -H "X-Parse-Application-Id: myAppId" \   
 -H "X-Parse-REST-API-Key:myRESTKey" \   
 -H "Content-Type: application/json" \   
 -d '{}' \  
 http://localhost:1337/parse/1/functions/hello

The response I get is

Cannot POST /parse/1/functions/hello

Which I take to be curls perfunctory statement that it cannot find a suitable POST endpoint

What is going wrong here? I have simply changed the sample curl example from Parse.com's documentation on using cloud-code to use my parse-server installation details

The answer is that unlike with Parses hosted solution the API version path is not something hosted with parse-server

if you host parse at e.g.: /parse as I have done above, then that is the relative URL where the functions API is available. So simply remove the /1/ from the path

The same curl command works with this URL

http://localhost:1337/parse/functions/hello

eg:

curl -X POST \   
-H "X-Parse-Application-Id: myAppId" \   
-H "X-Parse-REST-API-Key:myRESTKey" \   
-H "Content-Type: application/json" \   
-d '{}' \  
http://localhost:1337/parse/functions/hello