Merge pull request #4 from Procoder16/main
added proxy URL generation feature
This commit is contained in:
commit
58a80acfd5
10
README.md
10
README.md
|
@ -17,4 +17,14 @@ Proxify any image url, hide it and use anywhere.
|
|||
original_url = https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg
|
||||
proxified_url = https://img-proxy.vercel.app/fetch/image?key=aHR0cHM6Ly9jZG4ucGl4YWJheS5jb20vcGhvdG8vMjAxNS8wNC8yMy8yMi8wMC90cmVlLTczNjg4NV85NjBfNzIwLmpwZw==
|
||||
|
||||
|
||||
**GET** https://img-proxy.vercel.app/generate/image
|
||||
|
||||
Parameters(?) :-
|
||||
*url* -> image_url
|
||||
|
||||
Example :-
|
||||
request_url = https://img-proxy.vercel.app/generate/image?url=https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg
|
||||
response (json) = https://img-proxy.vercel.app/fetch/image?key=aHR0cHM6Ly9jZG4ucGl4YWJheS5jb20vcGhvdG8vMjAxNS8wNC8yMy8yMi8wMC90cmVlLTczNjg4NV85NjBfNzIwLmpwZw==
|
||||
|
||||
## Serverless API
|
|
@ -0,0 +1,19 @@
|
|||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const { base64encode } = require("nodejs-base64");
|
||||
|
||||
var Url2 = require("url-parse");
|
||||
var http = require("http");
|
||||
var https = require("https");
|
||||
|
||||
router.get("/proxyURL", async (req, res) => {
|
||||
const baseURL = req.protocol + "://" + req.headers.host + "/";
|
||||
var parts = new URL(req.url, baseURL);
|
||||
var encodedImageUrl = parts.searchParams.get("url");
|
||||
var imageUrl = base64encode(encodedImageUrl);
|
||||
|
||||
var proxyURL = baseURL + "fetch/image?key=" + imageUrl;
|
||||
res.json({proxyURL:proxyURL});
|
||||
});
|
||||
|
||||
module.exports = router;
|
|
@ -13,5 +13,6 @@ router.get("/", (req, res) => {
|
|||
});
|
||||
|
||||
router.use("/fetch", require("./fetch"));
|
||||
router.use("/generate", require("./generate"));
|
||||
|
||||
module.exports = router;
|
||||
|
|
Loading…
Reference in New Issue