diff --git a/.changeset/olive-cobras-bow.md b/.changeset/olive-cobras-bow.md new file mode 100644 index 000000000..9ea9aeac0 --- /dev/null +++ b/.changeset/olive-cobras-bow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Add warning on startup when `vite.server.fs.strict` is disabled diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index eb9591b4e..97be22abd 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -12,7 +12,6 @@ import { } from '../../integrations/index.js'; import { createVite } from '../create-vite.js'; import { info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger/core.js'; -import { nodeLogOptions } from '../logger/node.js'; import * as msg from '../messages.js'; import { apply as applyPolyfill } from '../polyfill.js'; @@ -65,6 +64,9 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro if (currentVersion.includes('-')) { warn(options.logging, null, msg.prerelease({ currentVersion })); } + if (viteConfig.server?.fs?.strict === false) { + warn(options.logging, null, msg.fsStrictWarning()); + } await runHookServerStart({ config, address: devServerAddressInfo }); diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index fcaec7bb1..0bd3f0d50 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -145,6 +145,10 @@ export function telemetryReset() { )}. You may be prompted again.\n`; } +export function fsStrictWarning() { + return yellow('⚠️ Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network!') +} + export function prerelease({ currentVersion }: { currentVersion: string }) { const tag = currentVersion.split('-').slice(1).join('-').replace(/\..*$/, ''); const badge = bgYellow(black(` ${tag} `));