From 9c2ba13748b975fb4b15b28b1b8ddc5ece3ccbb0 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Wed, 1 Jun 2022 18:32:29 -0400 Subject: [PATCH] Add console warning on fs.strict=false (#3464) * chore: add warning on fs.strict=false * chore: add changeset Co-authored-by: Nate Moore --- .changeset/olive-cobras-bow.md | 5 +++++ packages/astro/src/core/dev/index.ts | 4 +++- packages/astro/src/core/messages.ts | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/olive-cobras-bow.md 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} `));