[BUG] LargeFileUploadTask cors error
Describe the bug "Only seems to happen for personal accounts trying to use LargeFileUploadTask for upload to onedrive. LargeFileUploadTask works fine when used with a business account uploading both to a sharepoint document library or onedrive."
To Reproduce Steps to reproduce the behavior: 1.Login to personal account using msal2 provider and mgt-login 2. try to upload file const uploadTask = await OneDriveLargeFileUploadTask.create( graphClient, file, options ); 3.got error Access to fetch at 'https://api.onedrive.com/rup/24b5d554d8c0d12a/' from origin 'http://localhost:8081/' has been blocked by CORS policy: Request header field sdkversion is not allowed by Access-Control-Allow-Headers in preflight response.
Expected behavior file should be uploaded to one drive
Environment (please complete the following information):
- OS: Windows 10
- Browser Chrome -all browsers probably
- Framework Angular
- Context OneDrive
- Version latest "@microsoft/mgt": "2.4.0",
- Provider Msal2Provider
Additional context It does not work only with personal account probably connected with https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/265
Hello topce, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
Just to confirm, the Graph client you are getting is the one provided by MGT, right? I'm afraid this feature is not available yet in MGT (to prevent breaking changes).
You might need to rollout your own Graph client (https://www.npmjs.com/package/@microsoft/microsoft-graph-client) that is at the latest version, and you should be able to stop the CORS errors on the LargeFileUploadTask.
Let me know if this helps!
Hi @sebastienlevert Yes indeed I use Graph client from MGT. Not sure if it works even with latest version of MGC (did not check) Currently I patched mgt-element mgt-proxy-provider microsoft-graph-client in order to make it work.
Normally PR https://github.com/microsoftgraph/msgraph-sdk-javascript/pull/351 that suppose to fix issue https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/265 is merged into microsoft-graph-client 2.2.1 so in theory it should work, but not in practice ;-)
When MGT use latest version of MGC I will check if it works and remove my patch
Thank you for your help !
Adding @nikithauc to have a look from a Graph SDK lens.
Looks like MGT 2.6 takes on a dependency of the Graph JS library 2.2.1
Can you upgrade and verify if the issue persists @topce?
@nikithauc still same error : has been blocked by CORS policy: Request header field sdkversion is not allowed by Access-Control-Allow-Headers in preflight response. You can reproduce it yourself if you try to update to one drive : 1.Login to personal account using msal2 provider and mgt-login 2. try to upload file const uploadTask = await OneDriveLargeFileUploadTask.create( graphClient, file, options );
stack trace :
ERROR Error: Uncaught (in promise): Error: Failed to fetch
TypeError: Failed to fetch
at :8080/ui/polyfills.js:1826:30
at proto.