You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The easiest way to deploy is using the npm script which handles building and deploying:
14
14
15
15
```bash
16
-
npm install
17
-
```
18
-
19
-
### 2. Login to Cloudflare
20
-
21
-
```bash
22
-
npx wrangler login
23
-
```
24
-
25
-
### 3. Build the Project
26
-
27
-
```bash
28
-
npm run build:web
16
+
npm run deploy
29
17
```
30
18
31
-
This commands compiles the Rust code to WebAssembly and places the output in the `pkg/` directory.
19
+
This command runs `build:web` (compiling Rust to WASM) and then `wrangler pages deploy`.
32
20
33
-
### 4. Deploy to Cloudflare Pages
21
+
##Manual Steps
34
22
35
-
```bash
36
-
# Deploy to production
37
-
npm run deploy
23
+
If you prefer to run steps individually:
38
24
39
-
# Or manually:
40
-
npx wrangler pages deploy web --project-name evo
41
-
```
25
+
1.**Build Web Assembly**:
26
+
```bash
27
+
npm run build:web
28
+
```
29
+
*Output*: Generates `pkg/` and ensures `web/pkg/` contains the latest WASM.
42
30
43
-
This uploads the `web/` directory (which includes the index.html, CSS, JS, and the generated WASM in `web/pkg/`) to Cloudflare Pages.
31
+
2.**Deploy to Pages**:
32
+
```bash
33
+
npx wrangler pages deploy web --project-name evo
34
+
```
44
35
45
-
## Local Development
36
+
## Local Testing
46
37
47
-
Test the Pages build locally:
38
+
To simulate the exact Cloudflare environment locally:
48
39
49
40
```bash
50
41
npm run dev:worker
51
42
```
43
+
*Note: This uses `wrangler pages dev` which respects the `_headers` file.*
52
44
53
-
This builds the project and starts a local Pages server (using `wrangler pages dev`).
54
-
55
-
## Configuration
56
-
57
-
### COOP/COEP Headers regarding SharedArrayBuffer
58
-
59
-
The simulation uses `SharedArrayBuffer` for parallel processing (via `rayon`). This requires specific security headers to be served:
60
-
61
-
-`Cross-Origin-Opener-Policy: same-origin`
62
-
-`Cross-Origin-Embedder-Policy: require-corp`
45
+
## Critical Configuration: SharedArrayBuffer
63
46
64
-
These are configured in the `web/_headers` file, which Cloudflare Pages uses to apply headers.
47
+
This project uses multi-threading (`rayon`), which requires `SharedArrayBuffer`. This feature is only available in secure contexts with specific headers:
65
48
66
-
## Troubleshooting
49
+
-**Config File**: `web/_headers`
50
+
-**Required Headers**:
51
+
```
52
+
Cross-Origin-Opener-Policy: same-origin
53
+
Cross-Origin-Embedder-Policy: require-corp
54
+
```
67
55
68
-
### "SharedArrayBuffer is not defined"
69
-
If you see this error in the browser console, it means the COOP/COEP headers are missing. Ensure `web/_headers` exists and is being deployed.
56
+
**Troubleshooting:**
57
+
-**Error**: "SharedArrayBuffer is not defined"
58
+
-**Fix**: Ensure `web/_headers` exists and is deployed. Note that some local dev servers (like `python -m http.server`) do NOT send these headers. Use `npm run dev` (Node.js) or `npm run dev:worker` (Wrangler) for local testing.
0 commit comments