How to set up idrive e2 url?

I am using idrive e2 for storing images in respective folders. i can work it out on localhost where my backend runs on port 3000. in my imguploader function, i set the request url to localhost:3000/api/upload and it works. images do get uploaded to idrive. now that i’m changing to vps, i’m not sure what to put for url.

here’s the call from my imguploader utility in the frontend:

        const formData = new FormData();
        formData.append('file', file);

        const response = await axios.post(`https://icloud.heartstribute.com/api/upload/${userId}/${profileId}`, formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });

and then i have idrive.service.js in the backend:

import multer from 'multer';
import { fileURLToPath } from 'url';
import fs from 'fs';
import AWS from 'aws-sdk';
import { Router } from 'express';

const router = Router();

// Set up Multer for file uploads
const upload = multer({ dest: 'uploads/' });

// Get the directory name of the current module
const __filename = fileURLToPath(import.meta.url);

// Create an S3 client for IDrive Cloud
const endpoint = new AWS.Endpoint('s6k7.ph.idrivee2-37.com');
const s3 = new AWS.S3({
  endpoint: endpoint,
  signatureVersion: 'v4',
  s3ForcePathStyle: true,
  region: 'us-west-2',
  accessKeyId: "access-key",
  secretAccessKey: "secret-key"
});

const publicUrl = `https://b6e5.c19.e2-5.dev/heartstribute.bucket/`;

// CloudWatch client configuration
const cloudWatch = new AWS.CloudWatch({
  endpoint: endpoint,
  region: 'us-west-2', 
});


// Route to handle file upload
router.post('/upload/:userId/:profileId?', upload.single('file'), (req, res) => {
  console.log('Uploading file:', req.file);
  if (!req.file) {
    console.error('No file uploaded.');
    return res.status(400).send('No file uploaded.');
  }
  // get mime type of the file
  const fileType = req.file.mimetype;
  console.log(fileType);

  const fileStream = fs.createReadStream(req.file.path);

  const userId = req.params.userId; // Get user ID from request parameters
  const profileId = req.params.profileId;
  const folderPath = profileId === 'undefined' ? `ProfileManager/${userId}/${profileId}` : `ProfileManager/${userId}`;

  const params = {
    Bucket: 'heartstribute.bucket',
    Key: `${folderPath}/${new Date().toISOString()}-${req.file.originalname}`,
    Body: fileStream,
    ContentType: fileType,
    ACL: 'public-read',
    ContentDisposition: 'inline'
  };

  s3.putObject(params, (err, data) => {
    fs.unlinkSync(req.file.path);
    if (err) {
      console.error('Error uploading file: ', err);
      return res.status(500).send('Error uploading file: ' + err.message);
    }
    const fileUrl = publicUrl + params.Key;
    res.status(200).send({ message: 'File uploaded successfully', url: fileUrl });
  });
});

router.delete('/delete/:key', async (req, res) => {
  const { key } = req.params; 

  const params = {
    Bucket: 'heartstribute.bucket',
    Key: key,
  };

  try {
    await s3.deleteObject(params).promise();
    res.status(200).send({ message: 'File deleted successfully' });
  } catch (err) {
    console.error('Error deleting file: ', err);
    res.status(500).send('Error deleting file: ' + err.message);
  }
});
// Route to get metrics
router.get('/metrics', async (req, res) => {
  const params = {
    Namespace: 'AWS/S3',
    MetricName: 'BucketSizeBytes', 
    Dimensions: [
      {
        Name: 'BucketName',
        Value: 'heartstribute.bucket' 
      },
      {
        Name: 'StorageType',
        Value: 'StandardStorage'
      }
    ],
    StartTime: new Date(Date.now() - 24 * 60 * 60 * 1000), // Last 24 hours
    EndTime: new Date(),
    Period: 86400, // One day in seconds
    Statistics: ['Average']
  };

  try {
    const data = await cloudWatch.getMetricStatistics(params).promise();
    res.status(200).send(data);
  } catch (err) {
    console.error('Error retrieving metrics:', err);
    res.status(500).send('Error retrieving metrics: ' + err.message);
  }
});

router.get("/test", (req, res) => {
  res.send("Hello from the IDrive Cloud API!");
});

export default router;

i have tried changing the url to app.heartstribute but it gives cors error. either way, i’m not sure what to put for the call. can anyone tell me what the request url in my imguploader should be?

Right now, i get this error:

ChooseFile-2e204093.js:3
POST https://icloud.heartstribute.com/api/upload/hJ5mpV125BNEMktoMP9mcVRoXEw1/undefined net::ERR_NAME_NOT_RESOLVED

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật