Skip to content
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

The slidev:config plugin doesn't allow Vite to serve other html files #1923

Open
tschaub opened this issue Oct 31, 2024 · 0 comments · May be fixed by #1926
Open

The slidev:config plugin doesn't allow Vite to serve other html files #1923

tschaub opened this issue Oct 31, 2024 · 0 comments · May be fixed by #1926
Labels
bug Something isn't working

Comments

@tschaub
Copy link

tschaub commented Oct 31, 2024

Describe the bug

The slidev:config plugin configures the Vite dev server to load the built-in Vue index page for any request URLs ending with .html. This makes it so Vite cannot be used to serve additional pages that might be used as embedded iframes in a slideshow.

configureServer(server) {
// serve our index.html after vite history fallback
return () => {
server.middlewares.use(async (req, res, next) => {
if (req.url!.endsWith('.html')) {
res.setHeader('Content-Type', 'text/html')
res.statusCode = 200
res.end(options.utils.indexHtml)
return
}
next()
})
}
},

If a slideshow uses an <iframe> and the URL ends with .html, it will not be loaded by the dev server. A workaround is to use a URL that ends with .htm instead. See below for an example.

Minimal reproduction

Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/slidev-iframe-plugin?file=slides.md,vite.config.ts
  2. Advance the slideshow preview to see the working iframe on the second slide
  3. Advance to the next slide to see the broken iframe on the third slide
  4. See how it works when the iframe source URL ends with .htm instead of .html

Environment

  • Slidev version: 0.50.0-beta.5
  • Browser: Chrome 130
  • OS: macOS 14.7
@KermanX KermanX added the bug Something isn't working label Nov 1, 2024
@KermanX KermanX linked a pull request Nov 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants