Deploying traccar-web 5.8

corv2 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 Tananaev2 years ago

How do you access the API?

corv2 years ago

Remotely, via static-IP on port 8082

This seems to work fine in debug mode

Anton Tananaev2 years ago

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

corv2 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 Tananaev2 years ago

Usually you just replace the folder in Traccar.

corv2 years ago

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

corv2 years ago

Can you tell me how the proxy has to act?

Anton Tananaev2 years ago

Then you need a proxy.

corv2 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 Tananaev2 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.

corv2 years ago

Thank you very much, I got it working now

Proxying /api to localhost:3000 did the trick