A couple of issues regarding running traccar under a sub folder/directory/path

lj25 days ago

I have read about https://www.traccar.org/forums/topic/recompiled-modern-app-in-different-path-fails-to-call-server-api/

There are a couple of issues regarding the current guide:
https://www.traccar.org/secure-connection/
https://www.traccar.org/build-web-app/

First of all, there was never any mention of what should be done when recompiling the web app if someone wants to serve traccar under a subpath.

Some old posts refers to adding "homepage" to package.json which is no longer valid. You seems to switched to vite for building. So now we have to add base: '/gps', to vite.config.js, and this is no where mentioned in the documents.

Second, we need to rewrite /api to /gps/api, this is mentioned in the doc, but not emphasized. Besides if already specified with vite config, one would imagine /gps gets automatically prepended in front of api calls.

Third, even with the first 2 steps, I am stilling getting a blank page as mentioned in https://www.traccar.org/forums/topic/recompiled-modern-app-in-different-path-fails-to-call-server-api/

Upon some research, it seems that replacing BrowserRouter with HashRouter fixes the issue. I don't really know javascript so not sure if this is the best solution or not.

I hope the documentation can be improved to help other people. And if using HashRouter is the right way to do it, please change it in the code too. And the api calls should have /gps prepended automatically.

Thank you!

Track-trace25 days ago

Interesting, i would like to know to.

But why should you want to change the path in the first place ?
A single domain name for you tracking server with letsencrypt will set you back about 8 $ per year.
Looks much nicer to me anyway.

Anton Tananaev25 days ago

There have been a few recent discussions about it. My opinion is configuring a sub-path makes very little sense. Instead I recommend using a subdomain. What is the use case you need it for?

lj25 days ago

To Track-trace, I already have a domain name, so using a subdomain costs me $0...

It's just, like for you, using subdomain looks nicer, for me, using subpath looks nicer. I have a lot of services and I always use subpath.

To Anton, aside from aforementioned psychological reason, it's easier to manage reverse proxy (assuming it's supported) and DNS records. But it's not much big of a difference I'll admit. It's mostly just that I like to do it this way...And based on the recent discussion, and the fact that most popular self-hosted services provide this kind of baseurl setting, I think there are a lot of people like me who just prefer using subpath.

lj25 days ago

Also, subdomain exposes the services I am running (because of DNS records, A or CNAME), but subpath don't. All the outside world sees is one domain, they have no idea I got 10 or 20 services running in subpaths.

I'm sure some other people have other reasons too. Just from the fact that people are always demanding it we kinda see the value for it, I think.

Track-trace25 days ago

If you publish an app (to appstore, playstore) anyone can see where it connects to.

lj25 days ago

I don't need to...
Like for traccar I just use the official app and connect to my own server.

When I need to manage/view information, I just use web browser.

lj24 days ago

Deat Anton,

One more thing I just noticed, for the modern web app, when generating share device, the link is generated using setLink('${window.location.origin}?token=${token}') which ignores subpath setting.