-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Search doesn't work with basic auth. #87
Comments
Well, this is not a problem of the Material theme but a general problem with XHR on hosts with basic auth. Any suggestions? |
@squidfunk thanks for all your work, mkdocs-material 0.2.4 is great, 1.0.0 is even more ! I looked at the original mkdocs theme and the search_index.json is loaded with requirejs, and it works with basic auth. https://github.com/mkdocs/mkdocs/blob/master/mkdocs/assets/search/mkdocs/js/search.js#L5 |
I made it works again by adding the following code in <script type="text/javascript">
var require = {
baseUrl: './mkdocs/js',
paths: {
text: 'text'
}
}
</script>
<script src="./mkdocs/js/require.js"></script>
<script type="text/javascript">
require(['text!../search_index.json']);
</script>
|
Did you use Chrome? I think we just need to set some header and it should work - no need for require.js |
Yes |
The solution may be to include credentials in fetch : - return fetch(_this.config_.url.base + "/mkdocs/search_index.json").then(function (response) {
+ return fetch(_this.config_.url.base + "/mkdocs/search_index.json", {credentials: 'include'}).then(function (response) { https://github.com/squidfunk/mkdocs-material/blob/rework/src/assets/javascripts/application.js#L144 |
Should be fixed in |
@squidfunk Tested and it works good ! |
Awesome, thanks! |
Description
Search doesn't work if basic auth required.
Expected behavior
Fetch
search_index.json
return a 200Actual behavior
Fetch
search_index.json
return a 401Steps to reproduce the bug
Package versions
The text was updated successfully, but these errors were encountered: