BaGet
BaGet copied to clipboard
adding basepath support
Summary of the changes (in less than 80 chars)
- Adding full PathBase support
- Adding dynamic PathBase replacing in react scripts on StartUp of server
Addresses https://github.com/loic-sharma/BaGet/issues/276
Hi, this is awesome, thank you for opening this change! I wasn't sure how to share configs between the backend and the frontend, this is a really neat solution! I'm wondering, how did you choose to override the frontend configs when the app middleware is created in UsePathBase
?
I wonder if instead we should upgrade BaGet's AddSpaStaticFiles
. AddSpaStaticFiles
registers an ISpaStaticFileProvider
, which exposes an IFileProvider
(that IFileProvider
is actually a PhysicalFileProvider
). We could create our own ISpaStaticFileProvider
that has a custom IFileProvider
that replaces configurations lazily: it would return the IFileInfo
from the PhysicalFileProvider
if we detect no configs, otherwise we could create an in-memory IFileInfo
with the contents replaced. This has the added benefit that we don't mess with our UI's build artifacts. What do you think of that approach?
Thanks again for opening this, I really appreciate it! 😊
Hi, thnk you very much.
Using UseBasePath
was the most straight foreward approach for that.
I didn't dig to much into this but your approach seems to be a nicer way to do this.
So basically from the approach I took we have to always place our configuration in the UI files because I choosed a placeholder which will be replaced. So I would suggest to always have the files in-memory. From performance side there should be little to no impact. I think implementing shouldn't be that hard. I will try to make the required changes.
So
I made the required changes to get it to work with ISpaStaticFileProvider
.
Take a look at it and tell me your thoughts. I think its a quite neat way to have this in-memory but still with reasonable performance.
So with the latest commit tests are working again.
Still code cleanup needs to be done.
Also we should consinder to write some tests for the StaticFileProviding.
If you have time you can have a look at the implementation and tell me your findings.
The Placeholder for path base will be now set only in production mode of npm (npm run build
), if you use npm start
no relative path will be appended to the start.
Which changes have to be made for this PR to get merged?
I have to use BaGet with a custom PathBase
and implemented it for the backend in #114.
Please let me know if there is anything that I can do to complete this feature.
I don't know you need to ask @loic-sharma
Hi, I need this feature. Do you need help completing it? Have a nice day
I just took a look into the code and there is a lot of cleanup work that needs to be done. Some classes look more like Java code than C# and ASP.NET has a lot of patterns which the rest of BaGet is following.
Instead of writing dozens of review comments it would be easier for me to fix stylistic mistakes directly. @szwenni Do you want to give me push access to your fork or shall I open a new pull request?