-1

I developed a Spring Boot applications as backend service and for web/android i use Flutter.

The Android version from the Flutter App works fine, no errors nothing but the web version has an error if i try to make a http request

NotificationProvider (Sends the HTTPS requests) : https://pastes.dev/TNbKIu0C7P Spring Controller (Receives the HTTP requests): https://pastes.dev/vLnlafP8jO

On the App Start i send an /all request with the token to get all notifications from the database

In the Android App i get the content from the database but in the web version i got this error: ClientException: XMLHttpRequest error., uri=https://localhost:8080/all?bearer=token

Solutions like

The Flutter Web app is already on a server (using Apache)

pubspec.yml -> https://pastes.dev/hWWF0aNYxN

I tried to make a simple http request to get the content from the database but i got on the web version from the app the error that i wrote above.

  • Solutions like won't work for me – DasShorty Aug 24 '23 at 12:33
  • You either need to send CORS headers from the server - or have the built flutter app hosted by the same web server as the API (which isn't possible when debugging). One solution is to have two modes for the server: when debugging, include the CORS headers and when in production (built app launched from the same server) don't include them. The other workaround when debugging is to disable Chrome security as described in the link. (Note that even though you are running on the same machine as the server (e.g. localhost) this doesn't help as the API will be on, say, 8888 vs a random for debugger) – Richard Heap Aug 24 '23 at 15:28
  • Further note that sending CORS headers as part of the *request* does absolutely *nothing*. The server must send them as part of the *response*. – Richard Heap Aug 24 '23 at 15:30
  • You may want to read [ask] – Robert Aug 24 '23 at 23:44
  • @Richard Heap i tried sending the headers back in the response but i got the same error as before. – DasShorty Aug 25 '23 at 06:08
  • The Front and Backend are running on the same Apache instance – DasShorty Aug 25 '23 at 06:31

0 Answers0