'I am getting XMLHttpRequest Error when I am trying to connect to parse server from flutter web app

I am getting XMLHttpRequest error whenever I am trying to connect to parse server through the flutter web app. I found it to be CORS issue but don't know how to solve this. I did see the documentation of parse_server_sdk_flutter where it says for web support, "Due to Cross-origin resource sharing (CORS) restrictions, this requires adding X-Parse-Installation-Id as an allowed header to parse-server. When running via express, set ParseServerOptions allowHeaders: ['X-Parse-Installation-Id']" I have been looking everywhere to know where do I need to add this and how do I add this. Honestly, I don't know how to add this and which part of code to add this. I am stuck at this since couple of days. My whole project is based on this parse-server backend and I really don't know how to solve this issue. Please help!



Solution 1:[1]

Use ParseDioClient:

https://pub.dev/packages/parse_server_sdk_flutter

await Parse().initialize(
  clientCreator: ({
    bool? sendSessionId,
    SecurityContext? securityContext
  }) => ParseDioClient(
    sendSessionId: sendSessionId,
    securityContext: securityContext
  ),
);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P