none
CORS errors when accessing Gen2 REST api

    Question

  • Hi,

    How are cross origin requests handled using Gen2 api?

    When making a jQuery ajax GET call to the Gen2 REST api, I'm seeing the following error in the Chrome console:

    Access to XMLHttpRequest at 'https://myaccount1.dfs.core.windows.net/mycontainer1?recursive=false&resource=filesystem&sv=xyz' from origin 'http://localhost:62571' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    Tried a few things like specifying request headers, crossdomain, etc. but looks like unless the api (server) itself has an Access-Control-Allow-Origin response header, it will not work.

    So my question is, how do developers handle this? Since this is not provided by the api. 

    Thanks

    Friday, April 5, 2019 7:52 PM

Answers

  • Data Lake Storage Gen2 is built on top of Blob Storage, so any setting applied to Blob Storage, is inherited by Gen2.  Use Blob API / GUI to set Gen2.
    Tuesday, April 9, 2019 6:00 PM
    Moderator

All replies

  • Hello simplify3000 and thank you for your question.  This document details how to use CORS.  You can set the CORS policies for your storage account in the portal 

    or you can set it by REST api calls.

    Does this help at all?

    Tuesday, April 9, 2019 12:56 AM
    Moderator
  • Hi Martin,

    Thanks for the reply.
    It does help to start, but I still have a question...
    The options listed in your screen print and in the first link are for the Blob, File, Queue and Table services.
    Which of these should be chosen to apply to Gen2 calls?

    Looking at the documentation it looks like Gen2 REST api is listed separately from each of these 4 services.


    Thanks

    Tuesday, April 9, 2019 3:03 PM
  • Data Lake Storage Gen2 is built on top of Blob Storage, so any setting applied to Blob Storage, is inherited by Gen2.  Use Blob API / GUI to set Gen2.
    Tuesday, April 9, 2019 6:00 PM
    Moderator
  • Thanks, will try this out and see if it works.

    Tuesday, April 9, 2019 10:13 PM
  • Thank you.  If it works, please mark as answered.
    Tuesday, April 9, 2019 11:04 PM
    Moderator