0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-06 22:38:13 -05:00

🐛 Fix 404 errors

This commit is contained in:
Alejandro Alonso 2023-07-06 09:48:13 +02:00 committed by Andrey Antukh
parent 49df4a9404
commit bfc490bd63
5 changed files with 55 additions and 11 deletions

View file

@ -192,10 +192,18 @@ http {
}
location / {
location ~ ^/(/|css|fonts|images|js|wasm) {
}
location ~ ^/[^/]+/(.*)$ {
return 301 /404.html;
}
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
try_files $uri /index.html$is_args$args =404;
}
}
}

View file

@ -131,6 +131,15 @@ http {
location / {
add_header Cache-Control "no-cache, max-age=0";
location ~ ^/(/|css|fonts|images|js|wasm) {
}
location ~ ^/[^/]+/(.*)$ {
return 301 /404.html;
}
try_files $uri /index.html$is_args$args =404;
}
}
}

View file

@ -168,7 +168,16 @@ http {
location ~* \.(html).*$ {
add_header Cache-Control "no-cache, max-age=0" always;
}
location ~ ^/(/|css|fonts|images|js|wasm) {
}
location ~ ^/[^/]+/(.*)$ {
return 301 /404.html;
}
root /var/www/app/;
try_files $uri /index.html$is_args$args =404;
}
}
}

View file

@ -6,8 +6,10 @@
(ns app.main.ui.routes
(:require
[app.common.data.macros :as dm]
[app.common.spec :as us]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.users :as du]
[app.main.repo :as rp]
[app.main.store :as st]
@ -92,17 +94,33 @@
(defn on-navigate
[router path]
(if-let [match (match-path router path)]
(st/emit! (rt/navigated match))
(let [location (.-location js/document)
location-path (dm/str (.-origin location) (.-pathname location))
valid-location? (= location-path (dm/str cf/public-uri))
match (match-path router path)
empty-path? (or (= path "") (= path "/"))]
(cond
(not valid-location?)
(st/emit! (rt/assign-exception {:type :not-found}))
;; We just recheck with an additional profile request; this avoids
;; some race conditions that causes unexpected redirects on
;; invitations workflows (and probably other cases).
(->> (rp/cmd! :get-profile)
(rx/subs (fn [{:keys [id] :as profile}]
(if (= id uuid/zero)
(st/emit! (rt/nav :auth-login))
(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))))))))
(some? match)
(st/emit! (rt/navigated match))
:else
;; We just recheck with an additional profile request; this avoids
;; some race conditions that causes unexpected redirects on
;; invitations workflows (and probably other cases).
(->> (rp/cmd! :get-profile)
(rx/subs (fn [{:keys [id] :as profile}]
(cond
(= id uuid/zero)
(st/emit! (rt/nav :auth-login))
empty-path?
(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))
:else
(st/emit! (rt/assign-exception {:type :not-found})))))))))
(defn init-routes
[]

View file

@ -18,7 +18,7 @@
{::mf/wrap-props false}
[props]
(let [children (obj/get props "children")
on-click (mf/use-callback #(set! (.-href globals/location) ""))]
on-click (mf/use-callback #(set! (.-href globals/location) "/"))]
[:section.exception-layout
[:div.exception-header
{:on-click on-click}