Skip to content

fix: inject headers defined in vite config#2191

Merged
antfu merged 1 commit into
slidevjs:mainfrom
Nemikolh:joan/fix-dev-headers
Jun 2, 2025
Merged

fix: inject headers defined in vite config#2191
antfu merged 1 commit into
slidevjs:mainfrom
Nemikolh:joan/fix-dev-headers

Conversation

@Nemikolh

@Nemikolh Nemikolh commented Jun 1, 2025

Copy link
Copy Markdown
Contributor

Hey there! 👋 Thanks for the amazing project! 🤩

This PR fixes an issue that I've run into when trying to use @webcontainer/api with slidev. The problem is that slidev ignores the server.headers configuration when serving the initial page.

After this PR, the headers field will now be respected for vite.config.ts similar to this:

import { defineConfig } from 'vite';

export default defineConfig({
  server: {
    headers: {
      'Cross-Origin-Embedder-Policy': 'require-corp',
      'Cross-Origin-Opener-Policy': 'same-origin',
    },
  },
});

For applying the headers from that field, I've followed the same logic as vite does for static assets. See here.

Let me know if there's anything I should do! 🙌

@netlify

netlify Bot commented Jun 1, 2025

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit d4c14ce
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/683c8ebae0affb0008e579d1
😎 Deploy Preview https://deploy-preview-2191--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2191

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2191

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2191

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2191

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2191

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2191

commit: d4c14ce

@antfu
antfu merged commit 1536ad1 into slidevjs:main Jun 2, 2025
@Nemikolh
Nemikolh deleted the joan/fix-dev-headers branch June 6, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants