Skip to content

response url of file.save() returns address of localhost instead of public url #1944

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

Closed
manishsangwan opened this issue May 29, 2016 · 5 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed type:question Support or code-level question

Comments

@manishsangwan
Copy link

My server is hosted on aws ec2 instance. I am using elastic load balancer. Load balancer is using https. I am using nginx to send all requests on https://mydomain/parse to http://127.0.0.1:1337/parse

when i used serverURL as https://mydomain/parse i was getting same problem as issue 411

"error": {
    "code": 100,
    "message": "XMLHttpRequest failed: \"Unable to connect to the Parse API\""
  }

so i modified serverURL to https://localhost:1337/parse . Things started working. but when i save a file object the url in response i get is http://localhost:1337/parse/files/my-app-id/filename instead ofhttps://mydomain/parse/files/my-app-id/filename. hope it made myself clear. my code segments are given below.

parse server configuration:-

var api = new ParseServer({
     ....
     serverURL: http://localhost:1337/parse,
     publicServerURL: https://mydomain/parse,
     ....
    });

file object:-

var file = new Parse.File('file-name.jpg', data);
file.save(function (response){
    console.log(response.url);     //gives http://localhost:1337/parse/files/my-app-id/filename 
  });                                          //instead of https://mydomain/parse/files/my-app-id/filename
@manishsangwan manishsangwan changed the title response url of file.save() return address of localhost instead of public url response url of file.save() returns address of localhost instead of public url May 31, 2016
@ajamaica
Copy link

ajamaica commented Jun 5, 2016

Parse was made with the idea that every request has to enter the router again and again (They explain why at the F8 2015). So the serverURL is for the cloud code to hit the API again thats why localhost works great. You have to change the serverURL to the actual server (it can be localhost but files will have that problem) and publicServerURL to where the user clicks for the email password rest. I get the error but I recomend you to use the s3 adapter for files so you dont have to worry about it.

@flovilmart
Copy link
Contributor

The publicServerURL should be in use when using files if it was set at the time the file was created

@nicolasguzca
Copy link

+1

@hramos hramos added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 6, 2016
@flovilmart
Copy link
Contributor

Closing as unable to reproduce with the default file adapter and a public serverURL set. Please update to the lastest parse-server version and reopen with more details if the issue persists.

flovilmart added a commit that referenced this issue Sep 24, 2016
@tanzeelrana
Copy link

Hi,

I am getting the same issue

Steps That I followed :

1 - Initialized my Parse Javascript with the Public IP address and my appID
2 - uploaded a file
3 - downloaded the file and searched for the image url and I get localhost in it

--> I am doing all this in my ionic application which is running on localhost but this should not have any effect since I initialized my Parse with my Public IP address (my parse server is set up on a digital ocean droplet)

as you can see here :

image

I mean I know the server IP and I can easily replace the localhost with my server IP an I get the file displayed properly but is this the right practice ? shouldnt my server IP be stored in the file url and not localhost ?

Thanks :)

@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

7 participants