Conversation
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.HttpOverrides; | ||
| using Microsoft.Extensions.Options; | ||
| using System; |
There was a problem hiding this comment.
Please place put using System* first. Visual Studio can do this automatically if you enable the option Place 'System' directives when sorting usings under Text Editor > C# > Advanced.
There was a problem hiding this comment.
Okay i will change that in next commit. I wasn't aware of that option.
| public class ConfigureForwardedHeadersOptions : IConfigureOptions<ForwardedHeadersOptions> | ||
| { | ||
| public void Configure(ForwardedHeadersOptions options) | ||
| private BaGetOptions bagetOptions; |
There was a problem hiding this comment.
A few suggestions:
- Please add the
readonlyfield modifier to ensure no one accidentally modifies this value. - Please keep the options wrapped in a
IOptionsSnapshotto support automatic configuration reload. - Please prefix field names with an underscore so that you don't need to use
this.to refer to fields.
| private BaGetOptions bagetOptions; | |
| private readonly IOptionsSnapshot<BaGetOptions> _options; |
There was a problem hiding this comment.
I will update this also in next commit. I wasn't aware of the IOptionsSnapshot thing if I'm honest, but it makes sense.
There was a problem hiding this comment.
I couln't get it to work with IOptionsSnapshot because BaGetOptions and ConfigureForwardedHeadersOptions are in different scopes. Maybe you can get it to work.
| Console.WriteLine("Host Url: " + bagetOptions.HostUrl); | ||
| options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost; | ||
| options.AllowedHosts = new List<string>() { bagetOptions.HostUrl}; | ||
| }else |
There was a problem hiding this comment.
Please add new lines in between blocks:
if (...)
{
...
}
else
{
..
}
// Do not restrict to local network/proxy| { | ||
| if (!string.IsNullOrEmpty(bagetOptions.HostUrl)) | ||
| { | ||
| Console.WriteLine("Host Url: " + bagetOptions.HostUrl); |
There was a problem hiding this comment.
Can we remove this? Or do you think this will be useful for customers? If the latter, please log using an ILogger<ConfigureForwardedHeaderOptions> as not everyone has access to stdout to browse logs
There was a problem hiding this comment.
Mabe leaving it hast Debug message should be fine. If somehow problems occur you could enable debug and this might help.
I will take the logger framework. I wanted to change this before pull request but forgot it.
| public string PathBase { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The application Host without port number. If not set all hosts will be allowed. See https://github.com/aspnet/Announcements/issues/295 |
There was a problem hiding this comment.
Found it in your comments and it makes sense to explain why this is required.
src/BaGet.UI/src/index.tsx
Outdated
|
|
||
| import DisplayPackage from './DisplayPackage/DisplayPackage'; | ||
| import Upload from './Upload'; | ||
| import createBrowserHistory from 'history/createBrowserHistory'; |
There was a problem hiding this comment.
Forgot to remove it.
I tried adding the history to react router and setting the base path via the history.
But dom router does not support history so I had to use the basename option.
|
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 I wonder if instead we should upgrade BaGet's Thanks again for opening this, I really appreciate it! 😊 |
|
Hi, thnk you very much. 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. |
Uses in memory for all js files and index.html Some code cleanup is still neccessary but it works frm first testings For all other files that are not js files and not the index html PhysicalFileInfo is taken as fallback
|
So 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. |
Fixed Logger null error
|
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. |
src/BaGet.Core.Server/Configuration/ConfigureForwardedHeadersOptions.cs
Outdated
Show resolved
Hide resolved
src/BaGet/Startup.cs
Outdated
| if (env.IsDevelopment()) | ||
| { | ||
| spa.UseReactDevelopmentServer(npmScript: "start"); | ||
| //spa.UseReactDevelopmentServer(npmScript: "start"); |
There was a problem hiding this comment.
Do we need to support a custom host name while in development mode? That seems like a weird use case to me. Would it be better if we didn't support a custom host name while in development mode? The React development server is very useful :)
There was a problem hiding this comment.
Yeah you are right. I don't know enough about the react environment. But maybe it is possible to have like dev environment where homepage is set to "" and a prodution environment where homepage is set to __BAGET_PATH_BASE_PLACEHOLDER__. So that npm (react) build setups the runtime and the index.html relative paths correctly.
I will try to find a appropiate solution for that.
…ptions.cs Co-Authored-By: Loïc Sharma <sharma.loic@gmail.com>
…ly in production mode commented reactdevserver back in whoch will be used in dev mode
…to basePathSupport
|
The Placeholder for path base will be now set only in production mode of npm ( |
|
Which changes have to be made for this PR to get merged? |
|
I don't know you need to ask @loic-sharma |
Summary of the changes * `UsePathBase` only works if applied before any file servers * This is just a quick fix before #388 is merged
|
Hi, I need this feature. Do you need help completing it? |
|
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. |
Summary of the changes (in less than 80 chars)
Addresses #276