Commit e978eef
Fix Discord OAuth in iframed game by removing COOP from redirect page
Root cause: discord_redirect.html was served with Cross-Origin-Opener-Policy:
same-origin (from both nginx and coi-serviceworker.js). When the OAuth popup
navigates from Discord (COOP: unsafe-none) back to the redirect page (COOP:
same-origin), the COOP mismatch triggers a browsing context group switch that
permanently severs window.opener. Since BroadcastChannel is also partitioned
by top-level site, neither communication mechanism could deliver the token.
Fix: Remove COOP from discord_redirect.html specifically. It doesn't need
SharedArrayBuffer, so it doesn't need cross-origin isolation. With COOP:
unsafe-none, window.opener survives the Discord->redirect navigation chain
and postMessage works.
Changes:
- coi-serviceworker.js: Delete COOP header for discord_redirect.html navigations
- nginx config: Add specific location block without COOP for the redirect page
- discord_redirect.html: Add localStorage write as additional fallback
- common.js: Add requestStorageAccess + localStorage polling as last-resort
fallback (covers edge case where Discord itself sets COOP), plus dedup
guard to prevent double-handling when multiple mechanisms succeed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 16ae788 commit e978eef
File tree
4 files changed
+111
-8
lines changed- cmake/web
- assets
4 files changed
+111
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
436 | 445 | | |
437 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
438 | 488 | | |
439 | 489 | | |
440 | 490 | | |
| |||
582 | 632 | | |
583 | 633 | | |
584 | 634 | | |
| 635 | + | |
585 | 636 | | |
586 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
587 | 641 | | |
588 | 642 | | |
589 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
590 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
591 | 651 | | |
592 | 652 | | |
593 | 653 | | |
| |||
602 | 662 | | |
603 | 663 | | |
604 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
605 | 680 | | |
606 | 681 | | |
607 | 682 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | | - | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
65 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
66 | 79 | | |
67 | 80 | | |
68 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
| |||
0 commit comments