Search code examples
flutterproxyhttprequest

How do I find the origin url of a http request made by a mobile app?


I'm building a mobile app in Flutter that makes an http request to an API. My app doesn't have a backend, so I'm using a tool called KOR Connect to safely handle my API key. The tool requires a list of permitted origins that can make the request. If I was building a web app, I'd simply put in my site's url. However, I don't how to find the origin for mobile app. Is there even such a thing, and if so, where would I find it?


Solution

  • I think you should do it in a different way. You can fetch your api endpoints with fetch method of flutter or you can use a popular library like dio https://pub.dev/packages/dio. this is an example code fetching an api with dio:

    final response = await dio.post('https://www.yourwebsite.com/api/login', data: {'email': email, 'password': password});
    

    You can use a backend service like node.js or express.js to write api functionality which you can fetch from your app.

    If your request is about CRUD operations and you want to have a database, I would recomend you to check out firebase https://firebase.google.com/, which is the easiest approach to get started by handling data for and from your app. (firebase enviorenment also doesn't need you to handle any kind of secret) its creating a secure connection to your app