CORS Issue on uploading files to Workfront API using Firefly app | Community
Skip to main content
shelly-goel
Adobe Employee
Adobe Employee
May 5, 2021
Question

CORS Issue on uploading files to Workfront API using Firefly app

  • May 5, 2021
  • 1 reply
  • 2015 views

Getting below error even though appropriate headers are set

 

Access to fetch at '<workfront url>/attask/api/v12.0/upload' from origin 'https://localhost:9080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

 

headers being set:

headers: {
        'apiKey': '<key>',
        'Content-Type': 'multipart/form-data',
        'Access-Control-Allow-Origin': '*'
      }
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Adobe Employee
May 5, 2021

@shelly-goel - the CORS policy is set by the server (workfront in this case), and you can not bypass it by changing your UI code.

The recommended route would be: write a Runtime action to call the workfront API, processes the data, and returns it to the UI for rendering.

Adobe Employee
May 6, 2021
ok, in that case you could still use the Files SDK to receive the file from the UI. When the Runtime action calls Workfront API, instead of simply giving the file URL, you would stream the file to the post request to upload in the "multipart/form-data" way. Here is a sample code from quick Google search: https://stackoverflow.com/questions/44021538/how-to-send-a-file-in-request-node-fetch-or-node.