Closed panlina closed 5 years ago
@panlina Hello, how do you deal with this problem?
It can not be solved unless you modify the code. You may ask the author to take this into account.
panlina made a pull request that tries to address this but removes functionality that I'm not immediately prepared to ditch: https://github.com/jfhbrook/node-ecstatic/pull/237
If you can propose a concrete change that does what you need without removing the baseDir option, I'm all for it.
show-dir/index.js#L98: You can switch these two lines of code by option.
// let href = `${parsed.pathname.replace(/\/$/, '')}/${encodeURIComponent(file[0])}`;
let href = `${encodeURIComponent(file[0])}`;
The problem between absolute path and relative path can be solved.
Oh! If that's all that's needed I'll gladly change that behavior, I just need the time to manually QA it
Yes, that's all that is needed, but I think an option is not needed, just change it to be relative path.
Options are used to ensure that they do not conflict with the author's previous ideas.
Understood. That's what I'm asking at the end of my post.
Hi, I'm using ecstatic behind a proxy, something like proxying http://localhost/a to http://localhost:8080, where 8080 is the port ecstatic is listening to. The problem is that ecstatic uses absolute url for
href
, which resolves to a url where the file path is directly appended to the host part, instead of the current url. For instance, when browsing from http://localhost/a, clicking folderf
navigates to http://localhost/f/, instead of http://localhost/a/f/. I noticed that there's abaseDir
option, but it's irrelevant here since the base url(/a
) is already eaten by the proxy beforebaseDir
applies. Using relative url forhref
may be a solution, but I'm not sure whether you are using absolute path for some reason. How do you think?