mirror of
https://github.com/penpot/penpot.git
synced 2025-05-02 22:55:53 +02:00
🐛 Fix 404 errors
This commit is contained in:
parent
49df4a9404
commit
bfc490bd63
5 changed files with 55 additions and 11 deletions
|
@ -192,10 +192,18 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
location ~ ^/(/|css|fonts|images|js|wasm) {
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/[^/]+/(.*)$ {
|
||||||
|
return 301 /404.html;
|
||||||
|
}
|
||||||
|
|
||||||
add_header Last-Modified $date_gmt;
|
add_header Last-Modified $date_gmt;
|
||||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||||
if_modified_since off;
|
if_modified_since off;
|
||||||
expires off;
|
expires off;
|
||||||
|
try_files $uri /index.html$is_args$args =404;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,15 @@ http {
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
add_header Cache-Control "no-cache, max-age=0";
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,16 @@ http {
|
||||||
location ~* \.(html).*$ {
|
location ~* \.(html).*$ {
|
||||||
add_header Cache-Control "no-cache, max-age=0" always;
|
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/;
|
root /var/www/app/;
|
||||||
|
try_files $uri /index.html$is_args$args =404;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.routes
|
(ns app.main.ui.routes
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.config :as cf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -92,17 +94,33 @@
|
||||||
|
|
||||||
(defn on-navigate
|
(defn on-navigate
|
||||||
[router path]
|
[router path]
|
||||||
(if-let [match (match-path router path)]
|
(let [location (.-location js/document)
|
||||||
(st/emit! (rt/navigated match))
|
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? match)
|
||||||
;; some race conditions that causes unexpected redirects on
|
(st/emit! (rt/navigated match))
|
||||||
;; invitations workflows (and probably other cases).
|
|
||||||
(->> (rp/cmd! :get-profile)
|
:else
|
||||||
(rx/subs (fn [{:keys [id] :as profile}]
|
;; We just recheck with an additional profile request; this avoids
|
||||||
(if (= id uuid/zero)
|
;; some race conditions that causes unexpected redirects on
|
||||||
(st/emit! (rt/nav :auth-login))
|
;; invitations workflows (and probably other cases).
|
||||||
(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))))))))
|
(->> (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
|
(defn init-routes
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [children (obj/get props "children")
|
(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
|
[:section.exception-layout
|
||||||
[:div.exception-header
|
[:div.exception-header
|
||||||
{:on-click on-click}
|
{:on-click on-click}
|
||||||
|
|
Loading…
Add table
Reference in a new issue