mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-14 02:35:06 +00:00
@@ -29,7 +29,8 @@ function request(url, options = {}, settings = {}) {
|
||||
headers: {
|
||||
"User-Agent": userAgent
|
||||
},
|
||||
followRedirect: false
|
||||
followRedirect: false,
|
||||
throwHttpErrors: false
|
||||
}, options))
|
||||
} else {
|
||||
throw new Error("Invalid value for setting `request_backend`.")
|
||||
|
||||
10
src/site/api/404.js
Normal file
10
src/site/api/404.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const {render} = require("pinski/plugins")
|
||||
const constants = require("../../lib/constants")
|
||||
|
||||
module.exports = [
|
||||
{route: "/404", methods: ["GET", "POST", "PATCH", "DELETE"], code: async ({url}) => {
|
||||
const path = url.searchParams.get("pathname")
|
||||
const couldBeUsername = path.match(`^/${constants.external.username_regex}$`)
|
||||
return render(404, "pug/404.pug", {path, couldBeUsername})
|
||||
}}
|
||||
]
|
||||
@@ -1,3 +1,5 @@
|
||||
//- Needs path, couldBeUsername
|
||||
|
||||
include includes/error
|
||||
|
||||
doctype html
|
||||
@@ -8,3 +10,5 @@ html
|
||||
|
||||
body.error-page
|
||||
+error(404, "Page not found.")
|
||||
if couldBeUsername
|
||||
| Trying to access a user? #[a(href=`/u${path}`) Visit @#{path.slice(1)}]
|
||||
|
||||
@@ -19,7 +19,6 @@ subdirs("pug", async (err, dirs) => {
|
||||
// need to check for and run db upgrades before anything starts using it
|
||||
await require("../lib/utils/upgradedb")()
|
||||
|
||||
pinski.addRoute("/404", "pug/404.pug", "pug")
|
||||
pinski.setNotFoundTarget("/404")
|
||||
pinski.addRoute("/static/css/main.css", "sass/main.sass", "sass")
|
||||
pinski.addPugDir("pug", dirs)
|
||||
|
||||
Reference in New Issue
Block a user