How can I connect to Convex from Flutter?

Hello. I’m working on developing NextJS and Flutter apps. I’ve created a backend using Convex in NextJS. When calling the NextJS API from the Flutter app, I encounter errors with user authentication. Despite using the same Auth0 domain, how can I pass the authenticated user information from the API to Convex? await ctx.auth.getUserIdentity() returns null.

NextJS code

convex/users.ts
export const getUser = query({
  handler: async (ctx) => {
    const identity = await ctx.auth.getUserIdentity();

    return identity
  }
});

api/users/route.ts
export async function GET() {
  const user = await fetchQuery(api.users.getUser);
  return NextResponse.json(user);
}

Flutter code

Future<void> getUserAction(UserProfile? user) async {
    print("userId: ${user?.sub}");
    final url = Uri.parse('http://10.0.2.2:3001/api/users');
    try {
      final response = await http.get(url);

      if (response.statusCode == 200) {
        print(jsonDecode(utf8.decode(response.bodyBytes)));
      } else {
        print('Failed to load data');
      }
    } catch (e) {
      print('Error: $e');
    }
  }