minio / minio-js

MinIO Client SDK for Javascript
https://docs.min.io/docs/javascript-client-quickstart-guide.html
Apache License 2.0
961 stars 281 forks source link

Presigned URL is giving an error on dev environment - AnonymousRequestError: Presigned GET url cannot be generated for anonymous requests #1347

Open nikhilguptagl opened 2 months ago

nikhilguptagl commented 2 months ago

NOTE

If this case is urgent, please subscribe to Subnet so that our 24/7 support team may help you faster.

I am using presigned URL with this chunk of code -

try {
      const dataStream = await MinIO.presignedGetObject(
        bucketName,
        objectName,
        24 * 60 * 60
      );
      const response = await axios.get(dataStream, { responseType: "stream" });
      let xmlContent = "";
      for await (const chunk of response.data) {
        xmlContent += chunk.toString();
      }
      res.send({ fileObject: btoa(xmlContent) });
    } catch (error) {
      res.send({ message: `${ERRORMESSAGE_3} ${error}` });
      return null;
    }

On local machine when connected to minio in dev environment, it is working fine, but when application gets deployed to dev environment - it throws an error while fetching the assets from minio - AnonymousRequestError: Presigned GET url cannot be generated for anonymous requests

Minio config - endPoint: 'endpoint.name', port: 9000, useSSL: false, accessKey: 'accesskey', secretKey: 'secretKey',

prakashsvmx commented 2 months ago

Please check mc admin trace -v ALIAS for both the cases