question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`npm run dev` serves entire project directory

See original GitHub issue

Describe the bug When I run npm run dev, the entire project directory is included and served as static assets. For instance, I can go to http://localhost:3000/README.md and get a prompt to download this file. (The regular static assets are routed and served correctly – this is something extra on top of that.)

To Reproduce

  • Initialize a project with npm init svelte@next
  • Run npm run dev
  • Attempt to access any file relative to the project root through the server, e.g. http://localhost:3000/README.md

Expected behavior The project root is not served as static assets.

Information about your SvelteKit Installation:

Diagnostics
  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers System: OS: Linux 4.19 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (4) x64 Intel® Core™ i5-5200U CPU @ 2.20GHz Memory: 4.17 GB / 6.12 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.7.0 - ~/.nvm/versions/node/v14.7.0/bin/node npm: 7.6.3 - ~/.nvm/versions/node/v14.7.0/bin/npm npmPackages: @sveltejs/kit: next => 1.0.0-next.71 svelte: ^3.29.0 => 3.37.0 vite: ^2.1.0 => 2.1.5

  • Your adapter (e.g. Node, static, Vercel, Begin, etc…) Node

Severity Fairly severe – it makes it impossible to write routes that overlap with the project directory structure (e.g., a /data/[filename].json route that corresponds to a data/ directory of JSON files in the project root that I add additional information to before serving). I discovered it because I was trying to set up a route with parameters that corresponded to a folder structure in my project directory, and spent a while thinking it had to be stale service workers or cache issues before realizing that the files from the project folder itself, rather than just static/, were being served as static assets.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mohe2015commented, Apr 8, 2021

What about leaving this open as I think you would also need to change some configuration here then? And also this should probably be fixed before a 1.0 release so nobody forgets about it?

1reaction
mohe2015commented, Apr 7, 2021

This could also be a security issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run one 'npm start' for two different folders in my project ...
Let's say the server is in the 'Backend' folder and the frontend ... then, if you wanna run both servers, just type npm...
Read more >
How to simultaneously run the client and server instances of ...
Let's say you are building a full-stack app, using React on the front-end and Nodejs & ExpressJs on the backend. The first step...
Read more >
serve - npm
The quickest way to get started is to just run npx serve in your project's directory. If you prefer, you can also install...
Read more >
npm-run-script
Description. This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts.
Read more >
serve - npm
Static file serving and directory listing. Latest version: 14.0.1, last published: 3 months ago. Start using serve in your project by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found