mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
ip api test
This commit is contained in:
6
pages/api/ip.ts
Normal file
6
pages/api/ip.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
|
export default async function ip(req: NextApiRequest, res: NextApiResponse){
|
||||||
|
const ip = (req.headers['x-forwarded-for' || 'x-vercel-forwarded-for']);
|
||||||
|
res.json({ ip: ip });
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
import { NextApiRequest, NextApiResponse } from "next";
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import aws from "aws-sdk";
|
import aws from 'aws-sdk';
|
||||||
|
|
||||||
const { BUCKET, ACCESS_KEY, SECRET_KEY, ENDPOINT, REGION } = process.env;
|
const { BUCKET, ACCESS_KEY, SECRET_KEY, ENDPOINT, REGION } = process.env;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export default async function Storage(req: NextApiRequest, res: NextApiResponse)
|
|||||||
secretAccessKey: SECRET_KEY,
|
secretAccessKey: SECRET_KEY,
|
||||||
region: REGION,
|
region: REGION,
|
||||||
endpoint: ENDPOINT,
|
endpoint: ENDPOINT,
|
||||||
signatureVersion: "v4",
|
signatureVersion: 'v4',
|
||||||
};
|
};
|
||||||
|
|
||||||
let isTruncated: boolean | undefined = true;
|
let isTruncated: boolean | undefined = true;
|
||||||
@@ -40,7 +40,7 @@ export default async function Storage(req: NextApiRequest, res: NextApiResponse)
|
|||||||
}
|
}
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
'Cache-Control',
|
'Cache-Control',
|
||||||
"public, s-maxage=10, stale-while-revalidate=59"
|
'public, s-maxage=10, stale-while-revalidate=59'
|
||||||
);
|
);
|
||||||
res.json({ object: objects, size: Number(size.toFixed(2)) });
|
res.json({ object: objects, size: Number(size.toFixed(2)) });
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user