Skip to content

Commit

Permalink
fix: image upload cors
Browse files Browse the repository at this point in the history
created another instance of axios with credentials false and use it for aws apis
  • Loading branch information
thealpha93 committed Nov 18, 2021
1 parent 4191c86 commit 85cb242
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions services/PostService.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ async function uploadImage(imageFile, imageData) {
// console.log(imageData);
// console.log(s3Url);
try {
const response = await axios.post(
const credLessAxios = axios.create({ withCredentials: false});
const response = await credLessAxios.post(
`${s3Url}/dev/s3-presigned-url`,
imageData
);
// console.log(response.data);
//put with imageFile
const uploadUrl = response.data;
const uploadResponse = await axios.put(uploadUrl, imageFile);
const uploadResponse = await credLessAxios.put(uploadUrl, imageFile);
// console.log({ uploadResponse });
const imageUrl = uploadResponse.config.url.split("?")[0];
// console.log({ imageUrl });
Expand Down

0 comments on commit 85cb242

Please sign in to comment.