Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/allowed-hosts-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@open-slide/core": minor
---

Add `allowedHosts` to `open-slide.config.ts` so proxied domains (Coder, Codespaces, reverse proxies) can reach the dev and preview servers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use present tense in the changeset description.

Change “Add” to “Adds” to follow the repository’s changeset wording rule.

Proposed fix
-Add `allowedHosts` to `open-slide.config.ts` so proxied domains (Coder, Codespaces, reverse proxies) can reach the dev and preview servers.
+Adds `allowedHosts` to `open-slide.config.ts` so proxied domains (Coder, Codespaces, reverse proxies) can reach the dev and preview servers.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Add `allowedHosts` to `open-slide.config.ts` so proxied domains (Coder, Codespaces, reverse proxies) can reach the dev and preview servers.
Adds `allowedHosts` to `open-slide.config.ts` so proxied domains (Coder, Codespaces, reverse proxies) can reach the dev and preview servers.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/allowed-hosts-config.md at line 5, Update the changeset
description in allowed-hosts-config.md to use present-tense wording by changing
“Add” to “Adds,” without altering the rest of the description.

Source: Coding guidelines

5 changes: 5 additions & 0 deletions apps/web/content/docs/cli/dev.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ const config: OpenSlideConfig = {

export default config;
```

Accessing the dev server through a proxied domain (Coder, Codespaces, a
reverse proxy) and hitting `Blocked request. This host is not allowed.`?
Set [`allowedHosts`](/docs/reference/config#remote-ide--proxied-dev-server)
in the config.
24 changes: 24 additions & 0 deletions apps/web/content/docs/reference/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export default config;
default: 'first free port from 5173 upward',
description: 'Dev server port.',
},
allowedHosts: {
type: 'string[] | true',
default: "Vite's default host check",
description: 'Hostnames the dev/preview server responds to. `true` allows any host.',
},
build: {
type: 'OpenSlideBuildConfig',
default: 'all toggles on',
Expand Down Expand Up @@ -104,6 +109,25 @@ const config: OpenSlideConfig = {
The value is passed straight to Vite's `base` and to React Router's
`basename`, so client-side navigation matches the deployed path.

### Remote IDE / proxied dev server

Cloud workspaces (Coder, Codespaces, Gitpod, …) reach the dev server through
a generated domain, so Vite blocks the request with
`Blocked request. This host (…) is not allowed.` Allow your workspace domain
— a leading dot matches every subdomain:

```ts
const config: OpenSlideConfig = {
allowedHosts: ['.my-workspace.example.com'],
};
```

Or set `allowedHosts: true` to accept any host. Only do this on a trusted
network — it disables Vite's DNS-rebinding protection. The value is passed
straight to Vite's
[`server.allowedHosts`](https://vite.dev/config/server-options#server-allowedhosts)
and also applies to `open-slide preview`.

### Organizing many decks

`slidesDir` is a single path and decks must sit directly inside it
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type OpenSlideConfig = {
themesDir?: string;
assetsDir?: string;
port?: number;
allowedHosts?: string[] | true;
/**
* @deprecated Pick the UI language from the language switcher in the slide UI
* instead. When set, this only seeds the initial language until the user
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/vite/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function createViteConfig(opts: CreateViteConfigOptions): Promise<I
},
server: {
port: config.port ?? 5173,
...(config.allowedHosts !== undefined ? { allowedHosts: config.allowedHosts } : {}),
fs: { allow: [APP_ROOT, userCwd, slidesAbs, themesAbs, assetsAbs] },
},
build: {
Expand Down
Loading