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

[fix] correct message when serving with strict:false #2726

Merged
merged 1 commit into from
Nov 5, 2021
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/sharp-pillows-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] correct message when serving with strict:false
14 changes: 10 additions & 4 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,17 @@ prog
watcher.vite.httpServer.address()
);

https = https || !!config.kit.vite().server?.https;
open = open || !!config.kit.vite().server?.open;
const vite_config = config.kit.vite();

https = https || !!vite_config.server?.https;
open = open || !!vite_config.server?.open;

welcome({
port: address_info.port,
host: address_info.address,
https,
open,
loose: vite_config.server?.fs?.strict === false,
allow: watcher.allowed_directories(),
cwd: watcher.cwd
});
Expand Down Expand Up @@ -229,11 +232,12 @@ async function check_port(port) {
* host: string;
* https: boolean;
* port: number;
* loose?: boolean;
* allow?: string[];
* cwd?: string;
* }} param0
*/
function welcome({ port, host, https, open, allow, cwd }) {
function welcome({ port, host, https, open, loose, allow, cwd }) {
if (open) launch(port, https);

console.log(colors.bold().cyan(`\n SvelteKit v${'__VERSION__'}\n`));
Expand All @@ -254,7 +258,9 @@ function welcome({ port, host, https, open, allow, cwd }) {

if (exposed) {
console.log(` ${colors.gray('network:')} ${protocol}//${colors.bold(`${details.address}:${port}`)}`);
if (allow?.length && cwd) {
if (loose) {
console.log(`\n ${colors.yellow('Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network.')}`);
} else if (allow?.length && cwd) {
console.log(`\n ${colors.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => relative(cwd, a)).join(', '))}`);
}
} else {
Expand Down