I have a special URL that has been set somewhere else and CANNOT be changed.
mydomain.com/discountCards
I need to return a JSON, from my s3 bucket whenever a server sends a fetch call to mydomain.com/discountCards
The issue is:
I'm using a react app on mydomain.com with React-Router. So going to mydomain.com/discountCards displays a white react page (since nothing is at that url)
I'm trying to set up Cloudfront to directly link to the s3 JSON file which works - but the issue is:
it only works for mydomain.com/discountCards.json not mydomain.com/discountCards
So.... right now my s3 bucket has a file called discountCards.json - but I need that to be discountCard without the ".json".
Or something else?
How do I return this .json from my s3, as a specific domain, using AWS s3, cloudfront, and route 53?
Like I said, I got it all set up with cloudfront pointing to my s3 file, but it requires I include the file extension in the URL (which I cannot do, the url is already locked in stone at mydomain.com/discountCards not discountCards.json)
This is so that other websites and apps can fetch that URL and get a json returned. Any other way to achieve this?
So.... right now my s3 bucket has a file called discountCards.json - but I need that to be discountCard without the ".json"
Save your file discountCard.json as discountCard without .json extension. See the image below
Then on properties under metadata add content-type
to application/json
see image below
Accessing the bucket is now possible through this url https://s3.amazonaws.com/stackkkover/discountCards
This answer was inspired by this post https://stackoverflow.com/a/27046083/3521330
I hope this answer will be helpful. Thank you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With