Linking frontend with backend

I followed instructions at https://github.com/GIScience/openrouteservice-app and got my frontend running at localhost:3035
Then I followed instructions at https://github.com/GIScience/openrouteservice/blob/master/docker/README.md and got my backend running at localhost:8080
But my frontend is not linked to my backend, it’s linked to OpenRouteService server through an API Key.
What should I do in order to connect my frontend to my backend?
I searched for it but couldn’t find an answer for this.

Hi @caduguedess,

did you use the ors_local grunt task?
One of our external associates provided a commit that remaps the local backend endpoints, to avoid CORS issues.

I did never test this, but you either have to use his solution and use Node 13 (might have to adjust port here) or edit the ngconstant.local targets in the Gruntfile.js before you run grunt ors_local.

Depending on your usecase you might as well run into CORS with the second option, but it’s easy to test.

Best regards

Hi @amandus.
Actually I was grunting ors only, but even grunt ors_local still can’t find any address.
The local targets are already localhost, at least most of them.
You mean the production targets that should be changed? The production lines are filled with openrouteservice APIs, so I changed production directions in order to use my local backend, but it still gives me “Error No address could be found” in the client.
I’m not typing any address, I’m clicking in roads in the map view to select the start and end points.
I changed from
https://api.openrouteservice.org/v2/directions
to
http://api.localhost:8080/v2/directions
is it right?

Best regards.

Hi again,

Of course you can use the grunt task ors instead of ors_local you will only use a different set of ngconstant targets.
These tasks are defined at the bottom of the Gruntfile.js.

You have to change it to the exact endpoint you want to use, no api.localhost.
For your local backend if it is running it should be:
http://localhost:8082/ors/v2 but if your local backend is exposed at port 8080 (like you said) you might have to adjust the port number.
As a test, you can just paste the endpoint in your browser and check if you get a response from your local backend.

Best regards

Thanks for answering.

Maybe I’m missing something but at the bottom of repository page (https://github.com/GIScience/openrouteservice/blob/master/docker/README.md), in Checking session, it says that the server would be available to requests at localhost:8080 , why would it be 8082?
In browser I get the “ready” status response when querying localhost:8080/ors/health
I tried both http://localhost:8082/ors/v2 and http://localhost:8080/ors/v2 in Gruntfile.js but none of them linked the frontend to the backend, the “Error No address could be found” message persists.

Best regards

Ah, the address not found is a geocoding thing. That is not included in the ors backend. You either need to host a seperate pelias instance or use the (official) ors api for that endpoint.

In general the ORS backend only includes directions, isochrones and matrix. All other endpoints that we offer are separate services.

Try again with port 8080 if you get “ready” status there.
And even if you get “no address” error, try adding start and endpoint by rightclick to check if it computes a route.

Answer will follow

Best regards

I changed the line directions of local enviroment, as you said, and now it worked.
I was editing the productions lines and thats why nothing was happening.
The address http://localhost:8080/ors/v2/directions made it work.

Thanks for the help!

Best regards.