Coder Social home page Coder Social logo

Comments (4)

mholt avatar mholt commented on June 13, 2024

I bet the bug is here:

reqExt := path.Ext(r.URL.Path)

for _, ext := range rule.Extensions {
    if reqExt == ext {

"/" doesn't have a ".html" extension, so the comparison fails and the template doesn't get executed. Should be a simple matter of checking if the path is a directory first, and if so, if an index file exists.

Although, more middlewares are going to run into this issue. Right now the list of index files is actually defined in the browse middleware which the core fileServer references. But maybe this isn't the best way to do it.

Perhaps each middleware that needs it could have an IndexFiles []string field that the application sets. (Of course, then we have to decide if an empty list defaults to index.html... etc.) To make this work well, I need to finish refactoring the config package and get those generator (New()) functions out of the middleware packages.

Okay - in summary: the simple fix is to just have the template middleware look for index.<extension> if the request is to a directory. That could hold us over for now, maybe?

from caddy.

ciarand avatar ciarand commented on June 13, 2024

Yeah, that sounds reasonable. Though this was enough to hold me over for now:

rewrite / /index.html

from caddy.

mholt avatar mholt commented on June 13, 2024

@ciarand This fix will go out at the next release. Thank you again for your bug report!

from caddy.

ciarand avatar ciarand commented on June 13, 2024

Sounds great, thanks @mholt!

from caddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.