Repository navigation
'Unable to connect to Parse API' since enabling HTTPS #411
Description
Activity
Need a bit more context. Where is the code running / what type of client is making the request and gets this error?
Sure.
I'm using a chrome plugin called Postman to make the requests. Our ParseServer was created using this AWS-ParseServer guide. Here's the main part of our
index.jscode:... // parseServer var parseServer = new ParseServer({ appId: process.env.APP_ID, masterKey: process.env.MASTER_KEY, databaseURI: process.env.DATABASE_URI, cloud: __dirname + '/cloud/main.js', serverURL: process.env.SERVER_URL + process.env.PARSE_MOUNT, facebookAppIds: process.env.FACEBOOK_APP_IDS, fileKey: process.env.FILE_KEY }); // Node app var app = express(); // CORS app.use(cors()); // Server path and setup app.use(process.env.PARSE_MOUNT, parseServer); ...The error occurs when I make a
httpsPOSTrequest to any cloud function. By changing the request andserverUrltohttp, the error goes away.Any progress? same issue
We ended up setting
serverUrlprotocol ashttp. So whilst our client to server data is still sent via SSL, any self calls made by our server will be unsecure - at least until the issue resolves. Though I must say, we have not tried re-checking this issue since2.0.7.@omairvaiyani I wonder if it's because of MongoLab
I looked into the code at the time and am pretty sure it didn't have anything to do with MongoLab. From what I remember, the REST request made by the server never reached back to the server - the HTTP response code was
0. This might indicate some sort of firewall block?I think the more long-term fix would be to question why a REST call is being made by the server to itself? Should the code not be triggered locally?
@omairvaiyani we are still discussing the best model for how to handle this issue in the long term. In the meantime, you should be able to use
localhostin yourserverURLto avoid having unencrypted requests on the public internet.I moved everything over to be running off of https://localhost, install a self singed cert, but my dashboard is not loading the server. I can use the same usrl to interact with my cloud code, and can see the "unauthorized" message at the url on the browser, so i know thats the correct url for the server. the dashboard still errors with,
POST https://localhost/msz/parse/serverInfo net::ERR_CONNECTION_REFUSEDMy dashboard loads the server if i change it back to the external url, however the cloud code fails to interact with the database.
+1
Only the parse cloud code cannot connect to the server via https...Reacted by Sanket Chandrakant Gurav and Edgar Mendoza@Spacelapp We've set our serverUrl to 'localhost:port' to counter-act this.
I already tried this...but when I use a cloud function in my iOS app I get this error:
[Error]: { code = 100; message = "XMLHttpRequest failed: {}"; } (Code: 141, Version: 1.13.0)Could you show us your config parameters in node for ParseServer?
Sure:
var server = new ParseServer({ databaseURI: 'mongodb://USER:PASSWORD@localhost:27017/database', cloud: __dirname + '/cloud/main.js', appId: 'APP_ID', masterKey: 'MASTERKEY', serverURL: 'localhost:3000/parse', oauth: { facebook: { appIds: "FB_APPID" } } });7 remaining items
Have you tried the answers above you? Set
SERVER_URLashttp://localhost:[port]/[mount], even if your protocol isHTTPS.yes I have tried that, but it doesn't work for me.
I have fixed this issue. Reason behind this is that node rejects unauthorized TLS.
so just put
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";in my parse server instance file.
Reacted by WEBRENCE, sfsds, Thai Nguyen, tribeapp, Matthew Chun, Guopeng Liang, itzharDev, ali atwa, kkwilllo, Y. Luo and 3 moreReacted by itzharDev, Matthew Chun, ali atwa and kkwillloReacted by itzharDev, Matthew Chun, ali atwa, kkwilllo, Y. Luo and Rolando SanchezReacted by itzharDev, tribeapp, Matthew Chun, ali atwa, kkwilllo, Y. Luo and PrimusHere is what worked for me:
Environment: app deployed on AWS, with the load balancer configured for HTTPS
On the server side, where you configure parse-server, use HTTP in the serverURL configuration parameter. On the client side, use HTTPS when you initialize the Parse app/library.
My theory is that the load balancer is terminating HTTPS traffic, so from the load balancer to the instance, it might be HTTP traffic. In this case, if the parse-server is configured for a HTTPS URL, then it might be trying to listen on a different port or something screwy like that?
I'm not an expert on how the AWS architecture works under the hood, so my rationale might be way off or downright incorrect. If anyone can explain why this would work, please chime in.
Reacted by Kirill Dubovitskiy and WEBRENCEprocess.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
I am using Elastic Beanstalk as server and can I use this? May I put this in index.js?
parse-community/parse-server-example#199In case anyone is still having this issue, I had the same and managed to fix by changing my Server URL from
https://myapp.com/parsetohttps://www.myapp.com/parseReacted by Siddharth RameshReacted by Siddharth RameshReacted by Siddharth RameshThanks @natanrolnik! I resolved the same behavior (in development) changing form
http://docker:1337/parsetohttp://localhost:1337/parseThere is something wrong with the serverURL. The issue only occurred in beforeSave trigger for me. @gfosco please reopen the issue.
The serverURL is used in cloud code, it should 99% of the time be http://localhost:[port]/[mountPath].
If you're using https in node, i recommend you start a http sever as well listening on any different port from the https server and pass the host parameter to 127.0.0.1. This will allow communications only from the server itself.
Reacted by Brian Lockwood, trongv, Guopeng Liang and Serhiy ShkatuloReacted by Brian LockwoodReacted by Brian Lockwood and Serhiy ShkatuloI just encountered this issue. @flovilmart's response is correct for development (ie running the server locally), but the way I was able to fix it for running on Heroku was by using http instead of https in the serverUrl parameter. @w3care25's fix likely addresses the same issue, tho this is probably a bug.
Just had this issue. For me the problem was solved by replacing
cert.pemwithfullchain.pemcertificate (both from Let's Encrypt) in https server options. I found the issue by runningwget https://mypublicdomain.com:1337/parsewhich surprisingly returnedERROR: cannot verify mypublicdomain.com's certificateeven though web browser didn't have any problem. Solution was inspired by certbot/certbot#2026Reacted by DazChongWe also had this problem for migrating existing Mobile App from parse.com to self Hosted Parse server on AWS but as mentioned by someone in this thread we simply changed the URL from HTTPs to HTTP on load balancer and used HTTPs only on client side this seems working.
I am still having this problem. I had the parse server set up and both the iOS app and the parse dashboard were able to connect over http. I then changed the AWS load balancer to accept client side traffic on port 443 and set a valid SSL certificate. I changed the uri in the parse dashboard and the parse dashboard can connect fine still. I changed the uri in the iOS app and the iOS app cannot connect. If I enable port 80 on the AWS load balancer, the iOS app can connect fine regardless of what the uri is set to in the iOS app. The parse URL is currently defined as https://parse-server.com:443/parse in the iOS app. The parse iOS library seems to be ignoring both the "https" and the "443". Inside the parse-server I have serverURL: process.env.SERVER_URL || 'https://parse-server.com/parse'
Was there ever a solution for this? I tried https, http, parse app URL, and localhost in serverURL – none worked. Thoughts anyone?
The way I got it to work was by adding
import os os.environ["PARSE_API_ROOT"] = "http://db.myserver.co/parse"to settings.py
My Application is using the perfect storm, SSL, File Storage, Cloud code.
This meant that I couldn't set the server url env variable to localhost as this broke the file urls that were output.
After investigating the function code, I saw the the credentials are set before ever function execution, so
I ended up setting Parse.serverURL at the start of my functions that used Parse.queryThis "solved" the issue for me, I added this as an additional env var as above PARSE_API_URL
var ParseApi = process.env.PARSE_API_URL Parse.Cloud.define("name", function(request, response) { Parse.serverURL = ParseApi;
We've added SSL to our AWS-hosted ParseServer, but are receiving this error when running any CloudFunction:
We've updated our
serverUrlto havehttps. After a bit of digging around, I ran intoParseServer/middlewares.js#handleParseHeaders, where I logged thereq.protocol. It says the protocol ishttp, even though the requests are sent withhttps.Just for more info - we have not yet enabled SSL on the mongolabs database.
GETrequests work fine.