aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLia Lenckowski <lialenck@protonmail.com>2023-08-23 17:53:59 +0200
committerLia Lenckowski <lialenck@protonmail.com>2023-08-23 17:53:59 +0200
commitc85a846fcee843ae830d1acd0833ddf95fbb3d7e (patch)
treed0021a425f0094251cf48f501d1312f74946fe0c
parent49f8a190a5de848a834e82749799295fe9a4bc50 (diff)
downloadfastbangs-c85a846fcee843ae830d1acd0833ddf95fbb3d7e.tar
fastbangs-c85a846fcee843ae830d1acd0833ddf95fbb3d7e.tar.bz2
fastbangs-c85a846fcee843ae830d1acd0833ddf95fbb3d7e.tar.zst
make all urls relative
now works with url-rewriting reverse proxies, when BASE_URL is set correctly
-rw-r--r--frontend/admin.ts6
-rw-r--r--frontend/query.ts2
-rw-r--r--frontend/search.ts2
-rw-r--r--frontend/submit.ts2
-rw-r--r--src/Main.hs1
5 files changed, 7 insertions, 6 deletions
diff --git a/frontend/admin.ts b/frontend/admin.ts
index 1b6ba90..40a7a94 100644
--- a/frontend/admin.ts
+++ b/frontend/admin.ts
@@ -10,7 +10,7 @@ interface PendingBang {
async function sendVerdict(user: string, pw: string, b: PendingBang,
accept: boolean, info_block: HTMLDivElement)
{
- let err = await fetch(accept? "/acceptBang" : "/rejectBang", {
+ let err = await fetch(accept? "acceptBang" : "rejectBang", {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
@@ -26,12 +26,12 @@ async function sendVerdict(user: string, pw: string, b: PendingBang,
else
info_block.remove()
// TODO in the accept case, we should try invalidating the browser cache
- // for /bangs.json. My idea is to make a HEAD request to let the browser
+ // for ./bangs.json. My idea is to make a HEAD request to let the browser
// see that the etag has changed; idk of that works
}
export async function tryLoadAdminPanel(user: string, pw: string) {
- const r = await fetch("/pendingBangs", {
+ const r = await fetch("pendingBangs", {
headers: {
Accept: "application/json",
Authorization: "Basic " + btoa(`${user}:${pw}`),
diff --git a/frontend/query.ts b/frontend/query.ts
index e8d41b1..e67f09a 100644
--- a/frontend/query.ts
+++ b/frontend/query.ts
@@ -8,7 +8,7 @@ export function load_bangs() {
status("info", "Loading bangs...")
bangs = new Promise(r => {
(async () => {
- const bangs_res = await fetch("/bangs.json")
+ const bangs_res = await fetch("bangs.json")
if (!bangs_res.ok) return status("error", "could not download bangs.json")
const k: Bangs = await bangs_res.json()
status("info", "Bangs loaded.")
diff --git a/frontend/search.ts b/frontend/search.ts
index 40b7f91..02d8582 100644
--- a/frontend/search.ts
+++ b/frontend/search.ts
@@ -54,7 +54,7 @@ function link_engine(engine: string) {
rel: "search",
id: "search-link",
type: "application/opensearchdescription+xml",
- href: `/search.xml?default=${encodeURIComponent(engine)}`,
+ href: `search.xml?default=${encodeURIComponent(engine)}`,
title: `Fastbangs (default engine: ${engine})`
})
document.head.append(link)
diff --git a/frontend/submit.ts b/frontend/submit.ts
index e08e890..7010562 100644
--- a/frontend/submit.ts
+++ b/frontend/submit.ts
@@ -54,7 +54,7 @@ export function section_submit() {
async function submit_bang(submission: { bang: string, url: string, name: string, email: string }) {
status("info", "Submitting bang...")
- const r = await fetch(`/submitBang`, {
+ const r = await fetch(`submitBang`, {
method: "POST",
headers: {
"Content-Type": "application/json",
diff --git a/src/Main.hs b/src/Main.hs
index 540db63..74cc170 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -72,6 +72,7 @@ mkYesod "Search" [parseRoutes|
instance Yesod Search where
makeSessionBackend _ = return Nothing
+ approot = ApprootStatic ""
instance YesodPersist Search where
type YesodPersistBackend Search = SqlBackend