mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-28 14:23:04 +03:00
36 lines
920 B
JavaScript
36 lines
920 B
JavaScript
const cloudinary = require("cloudinary").v2;
|
|
cloudinary.config({
|
|
cloud_name: "dillonkearns",
|
|
api_key: process.env.CLOUDINARY_KEY,
|
|
api_secret: process.env.CLOUDINARY_SECRET,
|
|
});
|
|
|
|
exports.handler = async function (event, ctx) {
|
|
const recordId = event.path.replace(/^.*process-url\//, "");
|
|
|
|
try {
|
|
const screenshotUrl = `https://deploy-preview-176--elm-pages.netlify.app/screenshot/${recordId}`;
|
|
const imageUrl = cloudinary.url(
|
|
`https://res.cloudinary.com/dillonkearns/image/upload/v1621026065/elm-pages/1x1-ff00007f_rd0kpy.png`,
|
|
{
|
|
// resouce_type: "raw"
|
|
sign_url: true,
|
|
// secure: true,
|
|
custom_pre_function: {
|
|
function_type: "remote",
|
|
source: screenshotUrl,
|
|
},
|
|
}
|
|
);
|
|
return {
|
|
statusCode: 302,
|
|
headers: {
|
|
Location: imageUrl,
|
|
},
|
|
body: "",
|
|
};
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
};
|