0

I have a project, backend with Django and frontend with Flutter framework. The project was working fine until I changed the proxy in my Nginx from HTTP to HTTPS. Still working in most cases without any Problem. just in some cases, where I have no Data in my Data Table, I want/have to return an empty list from the backend, I got an error:

GET https://servername/project-name/api/commitments/?email=emailaddress%40companyname.de&jahr=2022&kunde=adac-ev 500
FormatException: SyntaxError: Unexpected token < in JSON at position 1

code in flutter:

  var uri = (APIPROTOCOL == 'http://')
        ? Uri.http(APIHOST, '/api/commitments/', uriQuery)
        : Uri.https(APIHOST, '$APIHOST_PREFIX/api/commitments/', uriQuery);
    try {
       final response = await http.get(
        uri,
        headers: {"Authorization": "Bearer $authToken"},
      );

And this is working on localhost and on a server with HTTP but the problem is only on a sever with HTTPS, any idea? how can debug the code on the server? or how can I change my localhost from http:://localhost:protNumber/ to something like https://servername/project-name/. Any idea that could help me to debug the code with https?

Davood
  • 353
  • 4
  • 14
  • [This is the JavaScript variant](https://stackoverflow.com/questions/37280274/syntaxerror-unexpected-token-in-json-at-position-0), but the problem is most likely the same. Your request is most likely responding with HTML instead of JSON. (Given the "500" in the error message, there likely is an error on the server's side.) – Ivar Jun 23 '22 at 12:38
  • @Ivar thank you for your response. Is there a way to run Django locally like ```https://localhost/app-name/```? – Davood Jun 24 '22 at 07:43

0 Answers0