Skip to content

Commit f1bf7a5

Browse files
authored
Instructions for running WebGL EW OAuth localhost
Signed-off-by: Firekeeper <0xFirekeeper@gmail.com>
1 parent 9713c2f commit f1bf7a5

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,36 @@ Notes:
5656
- Use `Smaller (faster) Builds` in the Build Settings (IL2CPP Code Generation in Unity 2022).
5757
- Use IL2CPP over Mono when possible in the Player Settings.
5858
- Using the SDK in the editor (pressing Play) is an accurate reflection of what you can expect to see on native platforms.
59-
- In order to communicate with the SDK on WebGL, you need to `Build and run` your project so it runs in a browser context.
6059
- In most cases, setting `Managed Stripping Level` to minimal when using IL2CPP is also helpful - you can find it under `Player Settings` > `Other Settings` > `Optimization`
6160

6261
## WebGL
6362

63+
- In order to communicate with the SDK on WebGL, you need to `Build and run` your project so it runs in a browser context.
6464
- Open your `Build settings`, select `WebGL` as the target platform.
6565
- Open `Player settings` > `Resolution and Presentation` and under `WebGLTemplate` choose `Thirdweb`.
6666
- Save and click `Build and Run` to test out your game in a browser.
6767

68-
If you're uploading your build, set `Compression Format` to `Disabled` in `Player Settings` > `Publishing Settings`.
68+
Important: If you're uploading your build, set `Compression Format` to `Disabled` in `Player Settings` > `Publishing Settings`.
69+
70+
Please note that Embedded Wallets (OAuth version) may not work when testing locally using Unity's default Build and Run feature for WebGL.
71+
72+
You must host the build or run it locally yourself after adding the `Cross-Origin-Opener-Policy` header and setting it to `same-origin-allow-popups`.
73+
74+
Here's a simple way to do so, assuming you are in your WebGL build output folder:
75+
```csharp
76+
const express = require('express');
77+
const app = express();
78+
const port = 8000;
79+
80+
app.use(function(req, res, next) {
81+
res.header('Cross-Origin-Opener-Policy', 'same-origin-allow-popups');
82+
next();
83+
});
84+
85+
app.use(express.static('.'));
86+
app.listen(port, () => console.log(`Server running on http://localhost:${port}`));
87+
```
88+
Once again, please note that no action is needed for hosted builds.
6989

7090
## Mobile
7191

0 commit comments

Comments
 (0)