Nuxt + AWS SDK + TS transpilation issue

I am using AWS JS SDK to get stuff from S3 via server on an API call. Using the client send method produces a [nuxt] [request error] [unhandled] [500] t is not a function. The reason I believe this to be a Cloudflare issue is because creating the application locally via nuxt build and nuxt preview does not produce the same issue. However, whenever I use wrangler or deploy to pages, the error occurs. The trouble code;
const command = new GetObjectCommand({
Bucket: "mybucket",
Key: "some-key"
})
console.log('sending')
const response = await client.send(command) // <--- Object.defineProperty called on non-object
console.log('response received') // <--- Not reached because of ^
const command = new GetObjectCommand({
Bucket: "mybucket",
Key: "some-key"
})
console.log('sending')
const response = await client.send(command) // <--- Object.defineProperty called on non-object
console.log('response received') // <--- Not reached because of ^
2 Replies
BigBallard
BigBallardOP2mo ago
AWS SDK I learned is not compatable because of some libraries using @smithy dependency which in turn uses node:fs which based on this discussion makes it a no go. Gonna have to migrate to another solution
GitHub
t is not a function - when I use @aws-sdk/client-s3 on a Cloudfla...
I am pretty lost as I am not understanding where this error is coming from, I am able to get this working my S3 service working on a usual node runtime, but I just get this error t is not a functio...
AGill
AGill2mo ago
checkout aws4fetch package which should work in CF workers: https://www.npmjs.com/package/aws4fetch
npm
aws4fetch
A compact AWS client for modern JS environments. Latest version: 1.0.20, last published: 6 months ago. Start using aws4fetch in your project by running npm i aws4fetch. There are 64 other projects in the npm registry using aws4fetch.

Did you find this page helpful?