Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daemswibowo/1220b0b244d827fc0545c131b56a6417 to your computer and use it in GitHub Desktop.
Save daemswibowo/1220b0b244d827fc0545c131b56a6417 to your computer and use it in GitHub Desktop.
Make private Trello board attachments publicly-available. https://glitch.com/edit/#!/private-trello-attachment-proxy
require('dotenv').config()
const express = require('express')
const fetch = require('node-fetch')
const app = express()
app.use('/', async (req, res) => {
// Attachment URL
const attachmentURL = "https://trello.com/1/cards/5e65954f0f343116e999658f/attachments/5e67a146876719748d64057b/previews/5e67a147876719748d6405ae/download"
// Add auth headers and request image
const image = await fetch(attachmentURL, {
method: "GET",
headers: {
Authorization: `OAuth oauth_consumer_key="${process.env.TRELLO_KEY}", oauth_token="${process.env.TRELLO_TOKEN}"`,
},
})
const buffer = await image.buffer()
// Set response headers
res.setHeader('content-type', image.headers.get('content-type'))
res.setHeader('content-length', image.headers.get('content-length'))
// Send file
res.send(buffer)
})
app.listen(3000, '0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment