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.

🐛 BUG: `/foldername` does not resolve to `/foldername/index.html` in development.

See original GitHub issue

Quick checklist

  • I am using the latest version of Snowpack and all plugins.

What package manager are you using?

npm

What operating system are you using?

macOS

Describe the bug

Virtual server will resolve URL’s with trailing slashes, /foldername/ will resolve to /foldername/index.html but /foldername will yield cryptic messages in the terminal:

[22:01:05] [snowpack] Error: /Users/roy/new-dir/_output/foldername/index.html - Requested content "" but only built .html
[22:01:05] [snowpack] [500] /foldername

This is not how browsers or Vercel serve works, with or without trailing slash should yield an index.html from inside a subfolder!

Thank you.

Steps to reproduce

  1. git clone https://github.com/revelt/snowpack-trailing.git
  2. cd snowpack-trailing
  3. npm run start
  4. OPEN NEW TAB IN THE TERMINAL
  5. open http://localhost:8080/sub — NOTICE NO TRAILING SLASH IS PRESENT

It won’t work until trailing slash is added!

Link to minimal reproducible example (optional)

https://github.com/revelt/snowpack-trailing

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Pyrolisticalcommented, Sep 7, 2021

@lgarron I deleted my previous comment and reworked the repo case.

Confirmed, reproduced on 3.8.8. My workaround was fixing the issue previously between server restarts

Repo case https://github.com/Pyrolistical/trailing-slash-regression

http://localhost:8080 ✅ works
http://localhost:8080/ ✅ works
http://localhost:8080/subfolder ❌ fails
http://localhost:8080/subfolder/ ✅ works

Also, the routes workaround does fix the issue!

routes: [
  /* This is the workaround */
  // {"match": "routes", "src": "/subfolder", "dest": "/subfolder/index.html"},
],

I do believe it is related to https://github.com/snowpackjs/snowpack/issues/3605#issuecomment-913947246

1reaction
Pyrolisticalcommented, Sep 7, 2021

Yes sorry, I meant #3521.

I need to be able to configure my dev to behave exactly like my production cdn or else I can’t use snowpack. It would cause too many “works on my machine” situations.

I would say the typical behaviour of production http servers is to rewrite both http://localhost:8080/subfolder and http://localhost:8080/subfolder/ to http://localhost:8080/subfolder/index.html if it exists, or else 404. But definitely not 500!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a required file. Name: index.html - Stack Overflow
When I move my public folder into the client folder and run npm start I get "Can't find file. Name: index.html. Searched in...
Read more >
`/foldername` does not resolve to `/foldername/index.html` in ...
I am using the latest version of Snowpack and all plugins. What package manager are you using? npm. What operating system are you...
Read more >
React: Could not find a required file : r/learnprogramming
Could not find a required file Name: index.html Searched in project public folder. But index.html is actually there in public folder when I ......
Read more >
could not find a required file. name: index.html - You.com
Run git status to view changed files. Open side panel. "Could not find a required file. Name: index.html" Error When Deploying React App...
Read more >
Using Different Names for Index Files
Our Web servers support a variety of index file names by default. ... the Web server won't be able to find the file...
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