-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only in Production - downloadDate and getUrl return "public/undefined" Signed URL, all other environments work even dev -> prod s3 bucket #14227
Comments
I just made all files in S3 public access, when I attempt to generate the URL or download with amplify, ONLY in production, it still returns this 404 /public/undefined for ANY string path I pass in. |
Hey @GrahamEvans31, thanks for opening this issue. Could you provide a full code example of the site where you are calling the |
|
Thanks for the quick reply @GrahamEvans31. Can you also provide a code example for the call site of the list API? |
ListBucket is not related, I can add ListBucket to the bucket and then it just 404's on the key that is produced inside the downloadData function. 'public/undefined' see top error line, also as explained this code generates correct signed URLs in all other environments. But when executing from Netlify production environment (dev works correctly, even dev->prod bucket) it always logs this error and has a bad key 'public/undefined' |
@GrahamEvans31, can you try assigning the path parameter to a variable and logging the output in your production environment to see what the output is? For example: const path = `public/metrics/${organizationId}/${year}/${("0" + month).slice(-2)}/CC.json`;
// log out path parameter
console.log(path);
const downloadResult = await downloadData({
path
}).result;
const text = await downloadResult.body.text();
const data = JSON.parse(text); |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Storage
Amplify Version
v6
Amplify Categories
storage
Backend
Other
Environment information
aws-amplify latest
Netlify
Everything runs correctly locally and even in the Netlify development website but when it makes it into production it fails. Development can access production S3 just fine but in production no access to production s3 bucket.
Describe the bug
When developing, I can access any S3 bucket either my dev or prod, no issues and correct signed URLs are generated. When I deploy into my Netlify dev. environment, same, not issues it works correctly. When my code is in production on a app.v2. endpoint, it is a subdomain not sure if there's a CORS issue here I tried many S3 bucket permissions changes trying to understand what potential environment differences. I generated production builds and ran them locally as well, these work fine locally but when the code is deployed into production, every call to generate a URL returns something like:
https://prod-rynsemedia.s3.us-west-2.amazonaws.com/public/undefined
even when I hardcode the input path, it returned this "undefined" URL. At first it said s3:ListBucket was not allowed, but it did work from all other environments including directly to this prod-rynsemedia bucket. I added the s3:ListBucket to the prod bucket and then the error for ListBucket disappeared but it still generated the '/undefined' URL and would say 404 object does not exist. I am unable to get either downloadData or getUrl to return correct URL's ONLY in the production environment hosted in Netlify. I've checked all environment variables, these are correct, there is almost no way for me to debug this issue that I can think of but it seems to be an issue within the aws-amplify code that is a silent error or sorts.
Expected behavior
Generate the correct signed URL location, not an "undefined"
Reproduction steps
Only in netlify production environment is an "undefined" URL location returned.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
Storage: {
S3: {
bucket: import.meta.env.VITE_S3_BUCKET,
region: import.meta.env.VITE_REGION
}
}
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: