-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
handle_errors 200 empty body #6422
Comments
Thanks for opening an issue! We'll look into this. It's not immediately clear to me what is going on, so I'll need your help to understand it better. Ideally, we need to be able to reproduce the bug in the most minimal way possible using the latest version of Caddy. This allows us to write regression tests to verify the fix is working. If we can't reproduce it, then you'll have to test our changes for us until it's fixed -- and then we can't add test cases, either. In this case, we especially need to reproduce this with I've attached a template below that will help make this easier and faster! This will require some effort on your part -- please understand that we will be dedicating time to fix the bug you are reporting if you can just help us understand it and reproduce it easily. This template will ask for some information you've already provided; that's OK, just fill it out the best you can. 👍 I've also included some helpful tips below the template. Feel free to let me know if you have any questions! Thank you again for your report, we look forward to resolving it! Template
Instructions -- please heed otherwise we cannot help you (help us help you!)
Example of a tutorial: Create a config file: |
I wasn't able to reproduce it with a curl command. I think it has something to do with some kind of caching and I'm not sure how to achieve that in curl. I was able to create a minimal setup that uses the browser. I created a basic project with a docker compose script below and you can reproduce it by navigating to http://localhost/test/me and refreshing the page with the keyboard shortcut I tested in in chrome and firefox along with in chrome and firefox in incognito mode |
You should use |
I'll have to give it a try tomorrow. I do think this is a bug though since it works as expected during navigation or a hard refresh but returns an empty body during a soft refresh |
If you could add the |
That sounds like a bug in the SPA 🤔 especially if it can't be reproduced with curl. Having to use the browser to reproduce a bug is almost always indicative of a bug in the web app or even the browser (we've seen both). |
@mholt It's not the spa, I reproduced it above with a bare html file. also, if you remove the
|
@mholt I just remembered that you can copy a network request as a curl command in chrome, and I was able to reproduce it with curl. you may have to run the curl command twice because the first request works, it's just subsequent ones
|
My gut tells me it has to do with the |
Alright, I was right. It has to do with the When using Ultimately, this is not a bug in Caddy. It's a user configuration error. The proper configuration is to follow @francislavoie suggestion and the doc page he linked to. |
if I remove the status 200 it consistently returns a 404, but I'm guessing that the browser don't pass cache headers on 404s? |
so I switched to try_files, and it is returning index.html for the favicon. I looked through the docs and wasn't able to find where {path} comes from or if there are other similar ones, because I think what I want would be closer to try_files {path} {filename}
|
Yeah, so you need to add a
It's a placeholder: https://caddyserver.com/docs/caddyfile/concepts#placeholders, it's the current request path.
No, that's wrong. That wouldn't do anything useful. |
I mentioned this, because I'd like caddy to return a 404 since there is not a favicon.ico
I was trying to achieve: /random/path -> random/path/index.png or /index.html or 404 I mentioned it above but it may have gotten missed: |
It was changed from 304 to 200 because you explicitly configured Caddy to do that. It'd be very strange to WARN for something the user explicitly configure here:
For your use case, I'm suspecting we're dealing with the XY Problem because in your original post you mentioned favicons. For favicon, the browsers actually request Regarding |
I think I found kind of an odd bug. I am using caddy as a static file server for a SPA, so if I get an error, I just want it to try again at the root directory -- mostly for index.html and favicon
this works, returns index page but the status is still 404 on the successful document, odd but ok looking at the docs seems to be by design?
This one however -- it works on the initial page load, but if you refresh the page it returns an empty body for the page request and the index.html file for the favicon
initial page load:
![image](https://private-user-images.githubusercontent.com/11347689/343892736-fe6ad14f-5ebd-4521-8182-c1bd3e47710c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3Nzk5ODIsIm5iZiI6MTcxOTc3OTY4MiwicGF0aCI6Ii8xMTM0NzY4OS8zNDM4OTI3MzYtZmU2YWQxNGYtNWViZC00NTIxLTgxODItYzFiZDNlNDc3MTBjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDIwMzQ0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA1MjI1Zjg1NzdjZjMwMmU0MDE4ODQxOGQ1ZGMwYmI3NjRmYTU4ZTY4YTZiYTIzMGVlNzA5M2Q2NDg4YzhkM2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.d6iwiiquD544yA45ZV3RehP95SS8NWUPC0t6QoJ4mVU)
![image](https://private-user-images.githubusercontent.com/11347689/343892920-0692bf7e-f375-4fff-9554-f222ebae7de0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3Nzk5ODIsIm5iZiI6MTcxOTc3OTY4MiwicGF0aCI6Ii8xMTM0NzY4OS8zNDM4OTI5MjAtMDY5MmJmN2UtZjM3NS00ZmZmLTk1NTQtZjIyMmViYWU3ZGUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDIwMzQ0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJhYWNmNmFlZmY5NmYwZGQ0ZTNlMDBiZDdhM2I2ZmE1ZDExZTI5NzNhMzgyOWM4N2MzNDM3ZjFjZjlkN2YyMjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.AtJU9fcRUC-tBnodCXM-wY0zEclOxlk1SKj4h6SyAn8)
page refresh:
![image](https://private-user-images.githubusercontent.com/11347689/343892449-fd19d87d-d2ae-45c5-9654-44985be45d2f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3Nzk5ODIsIm5iZiI6MTcxOTc3OTY4MiwicGF0aCI6Ii8xMTM0NzY4OS8zNDM4OTI0NDktZmQxOWQ4N2QtZDJhZS00NWM1LTk2NTQtNDQ5ODViZTQ1ZDJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDIwMzQ0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc1NjYyNDBhMDFjYWQ1ZjBlN2Q0ZjE0MjE0ZDIyMzFmNmM4MDU0YThkMjliMWM3NTI3NzhiNjA4MzI5MTNmYzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HQwSzIclGcMemxhOjel-lO_NgeL71XwCjeq5PNUO0iQ)
when doing a hard refresh you again get the correct response
I am assuming this is a bug with some kind of caching key mechanism in handle_errors?
The text was updated successfully, but these errors were encountered: