Deploying traccar-web 5.8

corva year 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 Tananaeva year ago

How do you access the API?

corva year ago

Remotely, via static-IP on port 8082

This seems to work fine in debug mode

Anton Tananaeva year ago

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

corva year 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 Tananaeva year ago

Usually you just replace the folder in Traccar.

corva year ago

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

corva year ago

Can you tell me how the proxy has to act?

Anton Tananaeva year ago

Then you need a proxy.

corva year 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 Tananaeva year 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.

corva year ago

Thank you very much, I got it working now

Proxying /api to localhost:3000 did the trick