I am trying to load files stored within a basecamp project into a pdf viewer in a react app.
When I get the data from the API, if I go to the link in app_download_url the file will open if I am logged in or ask for login info first.
When I try to make the call from the server with the users access token it gives a 404, if I make it from the client side it gives me a CORS error.
Here is the code from the server I am trying:
const response = await axios.get(url, {
method:'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Accept': 'application/pdf',
'Content-Type': 'application/pdf' // Adjust the content type according to your file type
},
responseType: 'stream'
});
the provided url is the app_download_url string return from the getDocuments call to the api.
In the client I have tried to load it directly into the PDF viewer, and tried to make an axios call and both give cors errors. I have tried withCredentials, and by providing the access token in the header.
Is the possible to do? What am I doing wrong? Any help would be awesome.