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] `/example.com/` does not resolve to `/example.com/index.html` in development.

See original GitHub issue

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager 7.15.0
  • I run Snowpack on macOS 10.15.7
  • I run Snowpack on node v16.2.0

Describe the bug

localhost:8080/example.com/ does not resolve localhost:8080/example.com/index.html in development. The presence of .com in the folder seems to trigger a heuristic for file extensions:

[18:19:57] [snowpack] Error: /Users/lgarron/Code/git/github.com/lgarron/snowpack-url-folders/public/example.com/index.html - Requested content ".com" but only built .html
[18:19:57] [snowpack] [500] /example.com/

To Reproduce

https://github.com/lgarron/snowpack-url-folders has a repro with two folders that each contain a simple index.html:

  • public/example/
  • public/example.com/

Repro steps:

git clone https://github.com/lgarron/snowpack-url-folders && cd snowpack-url-folders
npm install

npx snowpack dev

# This works
open http://localhost:8080/example/
# This doesn't work:
open http://localhost:8080/example.com/

Expected behavior

Whether a path resolves a folder to its index.html does not depend on whether any containing folders contain a period.

Anything else?

This comes about in practice because we have source/demo code for multiple sites in the same project, and the folders for those demos contain the domains for those sites:

https://experiments.cubing.net/cubing.js/twizzle.net/ https://experiments.cubing.net/cubing.js/alg.cubing.net/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lgarroncommented, Jun 30, 2021

Anyways, give snowpack@next a try if you’d like to try the fix.

🥳😍

Thanks, that seems to work perfectly! My current work involves such a folder, and it’s delightful to see it load directly. 😊

1reaction
lgarroncommented, Jun 30, 2021

Bugfix here: #3509

Thanks! I just tried it out. 😄

Good news: This seems to serve the correct body content.

Sad news: The content is served with application/octet-stream, which prevents the page from being loaded in a browser and triggers a download instead. 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Respond always with index.html - Stack Overflow
html for all URLs and that's what my server responds with. However, first request is never example.com/index.html , it's for example example.com ...
Read more >
Same-origin policy - Web security | MDN
The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a ......
Read more >
HTTP: Hypertext Transfer Protocol (article) - Khan Academy
For example, the most well known status code is 404 ("File not found"). ... Next, type a URL in the browser bar, like...
Read more >
Default Plesk web page or other incorrect web page is shown
To find the correct filename, contact the website developer. ... Log into Plesk; Go to Domains > example.com > File Manager ...
Read more >
How to Change your Default Index Page in the htaccess file
First the server will check for first.html, if it does not find a file with that name, it continues to index.htm and so...
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