Skip to content

fix: inject headers defined in vite config #2191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

Nemikolh
Copy link
Contributor

@Nemikolh Nemikolh commented Jun 1, 2025

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! 🙌

Copy link

netlify bot commented Jun 1, 2025

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.

Copy link

pkg-pr-new bot commented Jun 2, 2025

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
20 checks passed
@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