slidev icon indicating copy to clipboard operation
slidev copied to clipboard

fix: add `.trycloudflare.com` to allowedHosts when tunnel enabled

Open Copilot opened this issue 1 month ago • 2 comments

Vite 6.0.9+ blocks Cloudflare Quick Tunnel requests by default. When users run slidev --remote --tunnel, the tunnel URL is rejected with "Blocked request. This host is not allowed."

Changes

Modified packages/slidev/node/cli.ts to automatically add .trycloudflare.com to Vite's server.allowedHosts when both --tunnel and --remote flags are present:

server: {
  port,
  strictPort: true,
  open,
  host,
  force,
  // Allow Cloudflare Quick Tunnel domains when tunneling is enabled
  ...(tunnel && remote != null ? { allowedHosts: ['.trycloudflare.com'] } : {}),
}

The configuration only applies when tunneling is active (matching the condition at lines 203-206) and merges with any user-provided allowedHosts in their vite.config.ts.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>server.allowedHosts</issue_title> <issue_description>docker部署之后不能用域名进行访问 Blocked request. This host ("xxx.dkln.cn") is not allowed. To allow this host, add "xxx.dkln.cn" to server.allowedHosts in vite.config.js.</issue_description>

<agent_instructions>When tunneling via cloudflare (e.g. --tunnel), add .trycloudflare.com to Vite's allowedHosts configuration automatically.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@kermanx > This issue is not only valid for `slidev-theme-neversink` but also affects other themes like `@slidev/theme-seriph`. The breaking change was introduced in [Vite 6.0.9](https://github.com/vitejs/vite/blob/v6.0.9/packages/vite/CHANGELOG.md?rgh-link-date=2025-06-15T17%3A26%3A57.000Z). As a temporary workaround, you can downgrade Slidev to version 51.0.2 and Vite to 6.0.8.

In fact, you can just create a vite.config.ts besides your slides.md, and add the erver.allowedHosts configuration. The vite configs are expected to be merged.</comment_new>

  • Fixes slidevjs/slidev#2144

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Nov 14 '25 09:11 Copilot

Deploy Preview for slidev ready!

Name Link
Latest commit ff7b67b030be97c0abc64729e87151d064ef493a
Latest deploy log https://app.netlify.com/projects/slidev/deploys/6916f31908dd2d00089bb7cb
Deploy Preview https://deploy-preview-2346--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.

netlify[bot] avatar Nov 14 '25 09:11 netlify[bot]

Open in StackBlitz

@slidev/client

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

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

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

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

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

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

commit: ff7b67b

pkg-pr-new[bot] avatar Nov 14 '25 09:11 pkg-pr-new[bot]