Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Dec 15, 2023
1 parent 1f406f9 commit d751408
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ router.get(
"/resource/:id",
aw(async (req, res, _next) => {
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
const resp = await download(req.params.id, ip);
const headers = Array.from(resp.headers)
.filter(([key]) => !key.includes("content-encoding"))
Expand All @@ -109,7 +111,9 @@ router.post(
"/sparql-form",
aw(async (req, res, _next) => {
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
const result = await postSparqlQuery(req.body, ip);

res.render("sparql.html", {
Expand Down Expand Up @@ -160,7 +164,9 @@ router.post(
return;
}
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
const { message, valid } = await postContactForm(
req.body,
req.session.num1,
Expand All @@ -184,7 +190,9 @@ router.get(
const page = parseInt(req.query.page) || undefined;
const pageSize = parseInt(req.query.pageSize) || undefined;
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
res.render("gallery.html", {
page: await gallery(page, pageSize, ip),
pageTitle: WEBSITE_TITLE,
Expand All @@ -199,7 +207,9 @@ router.get(
const id = req.params.postId;
const slug = req.params.slug;
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
res.render("post.html", {
post: await getBlogPost(id, slug, ip),
pageTitle: WEBSITE_TITLE,
Expand All @@ -213,7 +223,9 @@ router.get(
const page = parseInt(req.query.page) || undefined;
const pageSize = parseInt(req.query.pageSize) || undefined;
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
res.render("blog.html", {
posts: await getBlogPosts({}, page, pageSize, ip),
pageTitle: WEBSITE_TITLE,
Expand All @@ -226,7 +238,9 @@ router.get(
"/",
aw(async (req, res, _next) => {
const ip =
req.headers["x-forwarded-for"] || req.socket.remoteAddress || req.ip;
req.headers["x-forwarded-for"]?.split(",")[0] ||
req.socket.remoteAddress ||
req.ip;
res.render("index.html", {
publicInfo: await getPublicInformation(ip),
pageTitle: WEBSITE_TITLE,
Expand Down

0 comments on commit d751408

Please sign in to comment.