How to create companion.app dynamically when same companion server used by multiple domain

Hello All,

I have created companion server with node and express server.
Single companion server is used by multiple domain.

How can i set below data dynamically

const { app: companionApp,emitter } = companion.app({
s3: {
getKey: ({ req, filename, metadata }) => ${metadata.prefix}/${filename},
key: process.env.COMPANION_AWS_KEY, // Pass access key directly
secret: process.env.COMPANION_AWS_SECRET, // Return secret key
bucket: process.env.COMPANION_AWS_BUCKET, // Bucket name
region: process.env.COMPANION_AWS_REGION, // AWS region
acl: ‘public-read’,
expires: 900

},

server: { host: ‘localhost:’+port },
filePath: path.join(__dirname, ‘download’),
corsOrigins: [‘*’],
secret: crypto.randomBytes(64).toString(‘hex’),
debug: false,
metrics:false,
});

I don’t understand what you are trying to do. Can you elaborate with as much detail as you have?

Here is my code
const { app: companionApp,emitter } = companion.app({
s3: {
getKey: ({ req, filename, metadata }) => ${metadata.prefix}/${filename},
key: process.env.COMPANION_AWS_KEY, // Pass access key directly
secret: process.env.COMPANION_AWS_SECRET, // Return secret key
bucket: process.env.COMPANION_AWS_BUCKET, // Bucket name
region: process.env.COMPANION_AWS_REGION, // AWS region
acl: ‘public-read’,
expires: 900

},
providerOptions: {
instagram: {
key: process.env.INSTAGRAM_CLIENT_ID,
secret: process.env.INSTAGRAM_CLIENT_SECRET,
redirectUri: ‘http://localhost:’+port, // Replace with your redirect URL
},
},
server: { host: ‘localhost:’+port },
filePath: ‘./download’,
corsOrigins: [‘*’],
secret: crypto.randomBytes(64).toString(‘hex’),
debug: false,
metrics:false,
});

Now i want update bucket name,key,secret based on requested domain let says if request comes from abc.com then use bucket x if request comes from xyz.com then use bucket y and
also providerOptions like instagram key and secret etc.

Companion doesn’t support multi-tenant setups unfortunately.

so is there any way that i can work around to make this work?

Use a single Companion instance and move the uploads to another bucket after the upload is done. It would probably mean waiting on the client till the upload is done and then sending a request to your own backend which moves the upload. Unfortunately Companion doesn’t have webhooks either to let your backend know when it’s done.

Thanks for your suggestion. Can it be possible with virtual host ?

Hello, I think you replied for s3 and i got that it is not possible, But is there any way that i can update provider option runtime?

You cannot update the options runtime, unless you patch Companion. However Companion does have event hooks that you can subscribe to to determine when an upload is done, and then potentially move the file to a different bucket, see Companion | Uppy

I understand for bucket i can move after upload, But i have different credential for each tenant for gdrive,facebook,etc, is there any way for update it.