retrievertech / seismogram-app

Seismogram web app
http://seismo.redfish.com/
2 stars 1 forks source link

Client references to server #2

Open tjesser-ucdavis-edu opened 5 years ago

tjesser-ucdavis-edu commented 5 years ago

Hi, I've been trying to get the seismogram-app working in a set of containers, and been having trouble finding all the places the client refers to the location of the server as localhost.

You can find my attempt here: https://github.com/tjesser-ucdavis-edu/docker-SKATE.

I'm using a Docker network to connect containers I created for the database, server, and client, and I've created patches to point the server to the database, but finding where the client refers to the server has been more difficult. Would you be able to point me to where in the code I can make that type of change?

For reference, the error(s) I get:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/query/stations. (Reason: CORS request did not succeed).

and I want to be able to tell the client to use the URL http://seismo-server-inst:3000/query/stations.

mariusnita commented 5 years ago

I think the server urls are contained here: https://github.com/retrievertech/seismogram-app/blob/master/client/src/browse/ServerUrls.svc.js

Basically if you access the website at https://foo.com, it'll connect to the server using https://foo.com:3000. It dynamically grabs the foo.com from the URL.

mariusnita commented 5 years ago

It would be nice to have a config file for this. Something like:

{
  "database": { "url": "...", "username": "...", "password": "...", "dbname": "..." },
  "skateServer": { "url": "...", "username": "...", "password": "..." }
}

Basically a central config that (a) services can use to instantiate/configure themselves, and (b) service A knows where to find service B.

From this you could auto-generate a server-url.js with contents

export let serverUrl = "<the_url>";

that ServerUrls.svc.js can import and use. This could be null by default and ServerUrls.svc.js can default to using $location if that's the case.