-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index pages appear to be invalid according to web standards (i.e. Apache MultiViews and others) #6947
Comments
@voidmain what would you expect from this "format" that you're suggesting? Like, it seems that the issue comes from Apache not liking the structure and names of the files. Given your example, what should be the expected behaviour of this format? |
I don't think this is just Apache. Most web servers (Caddy, Nginx, S3, CloudFront, CloudFlare, Google, etc) and web standards treat directories differently than files. More specifically, these URLs technically point to different resources according to the URL specification:
Here's what I would assume would be the way that Astro would have built the output:
This doesn't mangle anything and holds true to the file names and locations. By default, every web server I've ever encountered will serve these files like this:
This works because all web servers treat |
Hey @voidmain I think I agree with your assessment here. One thing to keep in mind though, is that not all web servers treat index.html as a special file. S3 is one that does not. You have to type I don't think we should add another option here, as that would make the code significantly more complex. Instead I think we can treat this as a bug fix. It's doubtful to me that anyone is expecting the current behavior here. But to be safe, we'd probably want to fix this in a |
That works for me. It sounds like this might not be in a release for a bit, so in the meantime, here's a workaround for anyone that stumbles on this issue:
Here's my integration code:
And here's how my navigation component is handling index pages:
This snippet strips off
|
Hello! This was (finally) merged with the new |
What version of
astro
are you using?2.0.15
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
nom
What operating system are you using?
Mac
What browser are you using?
All
Describe the Bug
When the build format is set to
file
, it looks like Astro is not generatingindex.html
files that would mimic the source. Additionally, this confuses web servers like Apache which does not really love when there is a file with the same name as a directory.Generally,
index.html
represent the directory listing for the path segment of the URL. This is consistent with the last 30 years of the web or so. I would expect that Astro would generate the appropriateindex.html
file from the correspondingsrc/pages/foo/index.astro
source. However, it instead createsbuild/foo.html
.Here's an example that causes some confusion:
This is a little surprising since I've defined a file named
index.astro
orindex.html
but both get compiled tofoo.html
. This behavior also clobbers other files such as thefoo.astro
in the parent directory. If you run this in most default web servers, the URL/foo/
won't resolve to anything even though the pagesrc/pages/foo/index.astro
does exist.The Stackblitz I created won't illustrate the issue exactly because it looks like Stackblitz is translating URLs. It does illustrate that the
foo.astro
is clobbered though. However, if you clone that project and build it locally, you'll see the full symptom and the issue with directory slashesA change of this build behavior is likely a breaking change, so I would recommend adding a new build format such as
fileIndex
or something like that.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ztkedn
Edits
Sunday April 30, 2023 - I added some additional information and update the Stackblitz to include the
foo.astro
file that gets clobbered.The text was updated successfully, but these errors were encountered: