How to config 'access-control-allow-origin' header on web server?

chuxuanhy9 years ago

Hello,

Has anyone succeeded in config 'access-control-allow-origin' header on the web server, I need some help to do this, please give me some advice!

Have a nice day.

Anton Tananaev9 years ago

If you take source code from GitHub, it already has required headers. Here is a new build:

https://www.dropbox.com/s/myt68q5u7fiz49r/tracker-server-jar-with-dependencies.jar?dl=0

chuxuanhy9 years ago

I have replaced the old one with your .jar on my server but I still got the following line in the console
"XMLHttpRequest cannot load http://xxx/api/device/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access."

Am I missing something?

Anton Tananaev9 years ago

Just look at the headers and see if it's there.

chuxuanhy9 years ago

Thank you, I have got it done!

I would like to ask another question, how can I config to let several accounts having same unique Id that generated by app client to view on the web server?

For example :

Acc A can add and view unique id 1234, 2345,4567

Acc B can also add and view unique id 1234

Acc C can also add and view unique id 2345

Anton Tananaev9 years ago

Sharing device will be available with next release. If you don't want to wait, you can try to compile Traccar from source. It's already implemented.

chuxuanhy9 years ago

Hello,

I tried compiling latest Traccar source using Netbeans, and ran server successfully. The latest version still displayed error if I added same device id in different accounts, was I missing something?

Anton Tananaev9 years ago

What's the error?

chuxuanhy9 years ago

I added the same device id to track and the following errors displayed :
"Unique index or primary key violation: "CONSTRAINT_INDEX_7 ON PUBLIC.DEVICE(UNIQUEID) VALUES ('891542', 1)"; SQL statement: INSERT INTO device (name, uniqueId) VALUES (?, ?); [23505-187] - JdbcSQLException (... < QueryBuilder:424 < DataManager:300 < DeviceServlet:75 < ...)"

Anton Tananaev9 years ago

It looks like you are trying to add a second device with same unique id.

chuxuanhy9 years ago

Yes, I asked you about this feature above, and "Sharing device will be available with next release. If you don’t want to wait, you can try to compile Traccar from source. It’s already implemented.", you said.

I would like to give different accounts the ability to track same device, is it possible for the git version?

Anton Tananaev9 years ago

Yes, but you need to SHARE the device using special screen (Settings->Users->Devices) in the web interface, not by creating a second device with same unique id.