gsakola Posted May 9, 2023 Share Posted May 9, 2023 I've uploaded flutter app to server. App works fine except for getting data using web API's on googling I came to the conclusion that I need to activate CORS on web server. Please let me know how can I activate CORS on server. username : ansaraf Quote Link to comment Share on other sites More sharing options...
Bailey Posted May 9, 2023 Share Posted May 9, 2023 Hey @gsakola could you please provide more information on what the issue you're getting is, and why you think you need CORS. I ask this as CORS is more of a code design or HTTP request pattern than a configuration toggle. Would be useful for some context to help you futher. Quote Link to comment Share on other sites More sharing options...
gsakola Posted May 10, 2023 Author Share Posted May 10, 2023 13 hours ago, Bailey said: Hey @gsakola could you please provide more information on what the issue you're getting is, and why you think you need CORS. I ask this as CORS is more of a code design or HTTP request pattern than a configuration toggle. Would be useful for some context to help you futher. first of all I'm new with web development. though I've written some API's in php but they are basically for my desktop app only. When I'm running my Flutter App from Desktop mode it works fine, but in Web Mode it throws error XMLHttpRequest error. On searching I came to know that it has something to do with CORS Quote Link to comment Share on other sites More sharing options...
Bailey Posted June 1, 2023 Share Posted June 1, 2023 Sorry for the delayed response, it appears you need to handle CORS yourself code-side. This medium article appears to explain how to fix this with relation to Flutter: https://medium.com/@mustafatahirhussein/xmlhttprequest-blocked-by-cors-policy-flutter-web-fix-6bebe09d059f Though I haven't vetted it myself. I also recommend reading what CORS itself is, so you have a better understanding of what it's trying to do: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.