Hello , I am using express middleweight with node to upload file. When i use login with instagram it’s not working showing bad url . Here is my code .
Server.js
require('dotenv').config()
const express = require('express')
const companion = require('@uppy/companion');
const app = express()
const port = process.env.PORT ?? 9051
const cors = require('cors');
const bodyParser = require('body-parser')
const {
S3Client,
AbortMultipartUploadCommand,
CompleteMultipartUploadCommand,
CreateMultipartUploadCommand,
ListPartsCommand,
PutObjectCommand,
UploadPartCommand,
} = require('@aws-sdk/client-s3')
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner')
const { STSClient, GetFederationTokenCommand } = require('@aws-sdk/client-sts')
const policy = {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Action: ['s3:PutObject'],
Resource: [
`arn:aws:s3:::${process.env.COMPANION_AWS_BUCKET}/*`,
`arn:aws:s3:::${process.env.COMPANION_AWS_BUCKET}`,
],
},
],
}
const companionOptions = {
providerOptions: {
instagram: {
key: process.env.INSTAGRAM_CLIENT_ID,
secret: process.env.INSTAGRAM_CLIENT_SECRET,
},
},
server: {
host: 'localhost:3020',
protocol: 'http',
corsOrigins: ['*'],
uploadUrls: ['*'],
},
filePath: './download',
corsOrigins: ['*'],
secret: process.env.COMPANION_SECRET,
debug: true,
};
const { app: companionApp } = companion.app(companionOptions);
app.use(cors({
origin: '*', // Allow requests from your client app
methods: ['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE', 'FETCH'],
allowedHeaders: ['Content-Type', 'Authorization'], // Add any other headers you want to allow
credentials: true,
}));
app.use(companionApp);
/**
* @type {S3Client}
*/
let s3Client
/**
* @type {STSClient}
*/
let stsClient
const expiresIn = 900 // Define how long until a S3 signature expires.
const server = app.listen(port);
companion.socket(server);
// === </some plumbing to make the example work> ===
And client side i am using
<script src="https://releases.transloadit.com/uppy/v4.3.0/uppy.min.js"></script>
<script>
let url = 'http://localhost:9051/';
this.uppy = new Uppy.Uppy();
this.uppy.use(Uppy.Dashboard,{
inline: true,
target: '#drag-drop-area',
showProgressDetails: true,
});
this.uppy.on('complete', (result) => {
debugger;
console.log('Upload complete! We’ve uploaded these files:', result.successful)
});
this.uppy.use(Uppy.AwsS3, {
shouldUseMultipart(file) {
// Use multipart only for files larger than 1MiB.
return file.size > 1 * 2 ** 20;
},
endpoint: url ,
getTemporarySecurityCredentials: typeof crypto?.subtle === 'object',
});
this.uppy.use(Uppy.Instagram, {
companionUrl: url,
});
this.uppy.use(Uppy.Url, {
companionUrl: url,
});
</script>
I have checked with example and try to follow same but still issue. can anyone help what i am doing wrong.