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.

Support foo/index.html -> foo/ without stripping ".html" from other paths?

See original GitHub issue

The standard behavior I’m used to from a static file serving program is that foo.html should be served as-is, but requests for foo/ should serve foo/index.html if it exists, rather than a directory listing. The new cleanUrls=false setting lets me prevent foo.html from redirecting to foo, but also loses the ability to serve foo/.

Are these two things intentionally part of the same setting? I’m not sure how to get back to a traditional behavior here. Thanks!

cleanUrls=true

  • foo/ (serves foo/index.html)
  • foo.html -> redirect -> foo

cleanUrls=false

  • foo/ (serves directory listing)
  • foo.html (serves as-is)

I would prefer:

  • foo/ (serves foo/index.html)
  • foo.html (serves as-is)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:22
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
donmccurdycommented, Jun 18, 2018

To phrase the issue a little more generally, I think the latest release has introduced some disconnect between the stated purpose of the package and its functionality:

Assuming you would like to serve a static site, single page application or just a static file (no matter if on your device or on the local network), this package is just the right choice for you.

It behaves exactly like static deployments on Now, so it’s perfect for developing your static project. Then, when it’s time to push it into production, you deploy it.

This description (especially the first paragraph) makes serve sound like a general-purpose static file server that can be used for local development and more. However, if you’re using anything other than Now static deployments for the production site, there is no combination of serve.json settings that will give consistent paths in both environments. I use Zeit Now for various projects and like it a lot, but I don’t use it for everything and (with the current config options) will need to stop using serve with projects that deploy to GitHub Pages, for example.

I realize consistency within the Zeit ecosystem is important, and it’s something I value about Zeit, so if this is all intended behavior I’ll certainly understand. But in that case I think the language in the readme describes this package as being more general-purpose than it is today.

0reactions
Jack-Workscommented, Sep 29, 2019

yes, my plain html file is getting broken. /foo/index.html loads ./x.js(which means /foo/x.js) but serve rewrite it to /foo/ then /foo and now my html breaks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to tell webpack dev server to serve index.html for any route
I found the easiest solution to include a small config: devServer: { port: 3000, historyApiFallback: { index: 'index.html' } }. I found this...
Read more >
Support optional public base path configuration #8540 - GitHub
I'm facing one situation which is that, in index.html some resource references are provided by other microservices but in same origin, ...
Read more >
Remove trailing slash and index.html in .htaccess
It is not exactly the answer to your question but you should think twice about removing trailing slashes for directories. The doc about...
Read more >
Pitfalls and Common Mistakes | NGINX
namei -om /path/to/check ... location /foo { root /var/www/nginx-default/; # [. ... http { index index.php index.htm index.html; server { server_name ...
Read more >
Template Designer Documentation - Jinja
if there is not, check for an attribute called bar on foo . ... For example, {{ name|striptags|title }} will remove all HTML...
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