Https://project.turris.cz/api/... redirects to non existing localised endpoint

Hi all,
I found following problem:

Some scripts in Turris OS calls API endpoints on project.turris.cz/api/...
i.e https://project.turris.cz/api/registration-lookup.txt and https://project.turris.cz/api/contract-valid.txt

Those https calls fail to return correct response due to following redirects:

root@turris:~# cat /etc/turris-version
3.9.6
root@turris:~# curl https://project.turris.cz/api/contract-valid.txt -IL
HTTP/1.1 302 FOUND
Server: nginx/1.10.3
Date: Fri, 23 Mar 2018 11:26:51 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Cookie
Location: https://project.turris.cz/cs/api/contract-valid.txt
Strict-Transport-Security: max-age=15768000

HTTP/1.1 405 METHOD NOT ALLOWED
Server: nginx/1.10.3
Date: Fri, 23 Mar 2018 11:26:51 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
Content-Language: cs
Allow: GET

Is it intended to have localised /api/... endpoints?
As it seems language redirect causes the problem.

Regards,
Jan Nakladal

Hi @mojeto.

Can you describe, what is the exact problem? Do you have some problem with registration of your Router or check the validity of your Router contract?

The /api URL is used with automated scripts on Routers and there are some parameters need to sent to the API. It is not intended to visit these URLs by a web browser or simply “curl” them.

If I run the scripts on my Routers, it works well and the API is answering as desired. Also outputs of the script are correct. 405 is maybe a bit confusing in command line but as I said, it is not intended to be human-readable.

API localization is probably not needed but entire web app is and there is no problem with running API behind cs/en prefix.

Hi @vojtech.myslivec,

You right.

On the beginning, I found unexpected (for me) value in config file and by investigating I found those urls and by calling them without parameters I’ve got 405 error and that confused me.

Thanks to your explanation I understand what’s going on now and everything seems to work as expected.

I’m sorry for false alarm.

Regards
Jan Nakladal

1 Like