Pinecone http post query in Flutter release not working

Hi, I am trying to call the Pinecone API in my Flutter app with:

final headers = {
      'Api-Key': apiKey,
      'accept': 'application/json',
      'content-type': 'application/json',
    };

    final requestBody = jsonEncode({
      'includeValues': false,
      'includeMetadata': true,
      'vector': encodedText,
      'topK': 10,
      'namespace': category,
    });

    try {
      final response = await http.post(
        Uri.parse(pineconeUrl),
        headers: headers,
        body: requestBody,
      );

I run into the issue where I get Dart/Flutter: Http request raises XMLHttpRequest error whenever I try to call the API in my release build. It works fine in my debug build. I’ve read it may be related to CORS, but after reading your doc I am not doing any localhost.

Hi @tengen,

Can you share the full error message you’re getting back? I want to make sure there isn’t any missing context in it.

I’m not able to get anything clearer from the error reporting. The code itself mentions it hits that line that reports XMLHttpRequest error when the error isn’t clear. I was able to fix it by “hosting” the pinecone query inside a Google cloud function with CORS enabled so I’m guessing the issue is the pinecone server is not CORS friendly with the http request (possibly API-wise it is, but it is not available in Dart).