Why Rest API's are not working in flutter web?

Viewed 2421

flutter web API

My API's are working fine in applications but if I'm trying to call API with web so API's are not working

API's are implemented with dio (https://pub.dev/packages/dio)

Welcome for the improvements and thanks in advance for solutions and suggestions.

1 Answers

This is a CORS (cross-origin resource sharing) issue. You need to enable the CORS request on your server-side to fix this. Depending on your setup, you won't be needing to make changes on the client app.

Common workarounds made here for development builds is by disabling security using --disable-web-security argument when the app is run.

Related