You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 rivejä
511 B

  1. import BackendConfig from "@/config/backend-config";
  2. export default async function handler(req, resp) {
  3. try {
  4. const { img } = req.query;
  5. var values = BackendConfig["uri"];
  6. var res = await fetch(`${values}${img}`);
  7. var buffer;
  8. if (res.ok) {
  9. buffer = await res.arrayBuffer();
  10. }
  11. resp.writeHead(200, {
  12. "Content-Type": "image/jpeg",
  13. "Content-Length": buffer.byteLength,
  14. });
  15. resp.end(Buffer.from(buffer), "binary");
  16. } catch (e) {
  17. console.log("error", e.message);
  18. resp.end(null);
  19. }
  20. }