Commit f3955bd9 authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by GitHub

Fix page auto-reload when there's a 404/500 page. (#2437)

parent a07c7c44
...@@ -14,7 +14,12 @@ export default () => { ...@@ -14,7 +14,12 @@ export default () => {
const res = await fetch(url) const res = await fetch(url)
const payload = await res.json() const payload = await res.json()
if (payload.invalid) { if (payload.invalid) {
location.reload() // Payload can be invalid even if the page is not exists.
// So, we need to make sure it's exists before reloading.
const pageRes = await fetch(location.href)
if (pageRes.status === 200) {
location.reload()
}
} }
} catch (err) { } catch (err) {
console.error(`Error with on-demand-entries-ping: ${err.message}`) console.error(`Error with on-demand-entries-ping: ${err.message}`)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment