Skip to content

Commit

Permalink
Revert Vite config recommendation change (doesn't work in test app)
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff committed Jan 20, 2024
1 parent 40de155 commit cb70d26
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ Cross-Origin-Opener-Policy: same-origin
If your development server uses Vite, you can do this by adding the following to your Vite configuration.

```javascript
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
plugins: [
{
name: 'configure-response-headers',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
},
},
},
],
```

### Vite Configuration
Expand Down
16 changes: 11 additions & 5 deletions docs/guide/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ optimizeDeps: {
To enable cross-origin isolation (required for origin private file system persistence) for the Vite development server, you can add this to your Vite configuration. Just don't forget to also configure your _production_ web server to use the same HTTP headers.

```javascript
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
plugins: [
{
name: 'configure-response-headers',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
},
},
},
],
```
19 changes: 13 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ export default defineConfig({
name: 'chrome',
},
},
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
},
},
optimizeDeps: {
exclude: ['@sqlite.org/sqlite-wasm'],
},
plugins: [
{
enforce: 'pre',
name: 'configure-response-headers',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
},
},
],
});

0 comments on commit cb70d26

Please sign in to comment.