-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
56 lines (54 loc) · 1.92 KB
/
Copy pathindex.html
File metadata and controls
56 lines (54 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tableau Card Engine</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #1a1a2e;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
</style>
</head>
<body>
<div id="game-container"></div>
<!--
Client-side 404 redirect guard
If the page is loaded from a nested file path (for example
`/example-games/gym/index.html`) the dev server's SPA
fallback returns index.html which can hide the fact the requested
file doesn't exist. Redirect such requests to a dedicated
/404.html page so users see a proper Not Found message instead of
the app silently booting from the wrong base path.
-->
<script type="module">
// Module-mode guard: we can safely read import.meta.env here.
(function () {
try {
const path = window.location.pathname || '/';
// Detect deep-linked example game file paths or other nested index.html
if (/\/example-games\//.test(path) && !/^\/(|index\.html)$/.test(path)) {
const base = (import.meta && import.meta.env && import.meta.env.BASE_URL) ? import.meta.env.BASE_URL : '/';
const target = base + '404.html';
// Avoid redirect loop if already at 404
if (path !== new URL(target, window.location.origin).pathname) {
window.location.replace(target);
return;
}
}
} catch (e) {
// Fail closed: if the guard errors, continue booting the app.
// eslint-disable-next-line no-console
console.debug('[404-guard] check failed', e);
}
})();
</script>
<script type="module" src="/main.ts"></script>
</body>
</html>