serve everything under the /njump/ path to prevent conflicts with root domain website.

This commit is contained in:
fiatjaf
2023-05-27 08:42:11 -03:00
parent f9a85a7de1
commit 65a61cdcd6
4 changed files with 9 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ func generate(w http.ResponseWriter, r *http.Request) {
code := r.URL.Path[1+len("image/"):] code := r.URL.Path[1+len("image/"):]
if code == "" { if code == "" {
fmt.Fprintf(w, "call /image/<nip19 code>") fmt.Fprintf(w, "call /njump/image/<nip19 code>")
return return
} }

View File

@@ -11,9 +11,9 @@ var log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stdout}).
With().Timestamp().Logger() With().Timestamp().Logger()
func main() { func main() {
http.HandleFunc("/image/", generate) http.HandleFunc("/njump/image/", generate)
http.HandleFunc("/proxy/", proxy) http.HandleFunc("/njump/proxy/", proxy)
http.Handle("/static/", http.FileServer(http.FS(static))) http.Handle("/njump/static/", http.StripPrefix("/njump/", http.FileServer(http.FS(static))))
http.HandleFunc("/", render) http.HandleFunc("/", render)
port := os.Getenv("PORT") port := os.Getenv("PORT")

View File

@@ -149,7 +149,7 @@ func render(w http.ResponseWriter, r *http.Request) {
textImageURL := "" textImageURL := ""
description := "" description := ""
if useTextImage { if useTextImage {
textImageURL = fmt.Sprintf("https://%s/image/%s", hostname, code) textImageURL = fmt.Sprintf("https://%s/njump/image/%s", hostname, code)
if subject != "" { if subject != "" {
description = fmt.Sprintf("%s -- %s", subject, seenOnRelays) description = fmt.Sprintf("%s -- %s", subject, seenOnRelays)
} else { } else {
@@ -181,7 +181,7 @@ func render(w http.ResponseWriter, r *http.Request) {
"videoType": videoType, "videoType": videoType,
"image": image, "image": image,
"video": video, "video": video,
"proxy": "https://" + hostname + "/proxy?src=", "proxy": "https://" + hostname + "/njump/proxy?src=",
"eventJSON": string(eventJSON), "eventJSON": string(eventJSON),
} }

View File

@@ -45,7 +45,6 @@
{{end}} {{end}}
<!-----------> <!----------->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/static/styles.css?v=20230527" /> <link rel="stylesheet" href="/njump/static/styles.css?v=20230527" />
</head>
</head>