Deploying traccar-web 5.8

corv 3 years ago

Hi, I'm having trouble deploying traccar-web tagged 5.8

When running npm start everything works fine. However when I run npm run build and then serve -s build the browser shows Unexpected token '<', "<!doctype "... is not valid JSON

What could be the issue?

Any help is greatly appreciated, thanks

Anton Tananaev 3 years ago

How do you access the API?

corv 3 years ago

Remotely, via static-IP on port 8082

This seems to work fine in debug mode

Anton Tananaev 3 years ago

In debug mode there's a proxy. That's why I'm asking the question.

corv 3 years ago

I see. This is the first time I'm deploying, so I'm not sure what I need to do there.

Sorry if this question was asked before!

Anton Tananaev 3 years ago

Usually you just replace the folder in Traccar.

corv 3 years ago

Hm, ideally I would like to run the front-end separately from the Java backend and database

corv 3 years ago

Can you tell me how the proxy has to act?

Anton Tananaev 3 years ago

Then you need a proxy.

corv 3 years ago

Hello again,

First of all thank you for your outstanding software and for taking the time to respond so quickly.

I have now compiled the Java backend and it's running locally alongside the React web app. However the issue still persists.

I still don't understand why a proxy is necessary and how it has to be configured. I am aware the API uses both REST and WebSocket on port 8082 by default.

I see there are instructions here https://www.traccar.org/secure-connection/ is that the kind of setup you are referring to?

I would be very grateful for a more specific answer

Anton Tananaev 3 years ago

The proxy is needed because the web app expects the API to be available on the same URL. You need to proxy /api path.

corv 3 years ago

Thank you very much, I got it working now

Proxying /api to localhost:3000 did the trick