mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.25k stars 144 forks source link

[Question] Am I no longer server authorative with Fluxor? #255

Closed pingu2k4 closed 2 years ago

pingu2k4 commented 2 years ago

Hey, using Blazor server here. My question - I believe that stores can be modified by the user on their end, but does this get pushed back to the server, or are they simply seeing modified data their end that won't make any difference?

Take the counter sample - You can walk back how the page looked with lower counts using the redux devtools. Is this simply showing what the page was like moments after the action you step back to looked like, or is it pushing anything back to the server at all? A user could, I would imagine (I haven't been able to figure out how myself), try setting the store to have the current count be 100. What happens then, and what happens when I hit count++ button?

My guess is nothing, the devtools don't know what the page should look like with this altered state as we haven't seen it before, and it just allows you to step back to see the changes. And when you press the button, it continues counting from where it really is...

I just want to double check though as I don't want users to be able to have the server side think the wrong thing of course.

mrpmorris commented 2 years ago

Blazor Server only sends UI differences, no actual state is stored in the browser.

However, if you enable ReduxDevTools middleware then the user can modify the state and set it to whatever they want. You should only use that middleware for development.

pingu2k4 commented 2 years ago

Aologies for reopening - I am only using redux dev tools when builder.Environment.IsDevelopment() is true, however in release mode the redux dev tools appears to be just as functional as it was before?

Is there something I need to do to "turn off" the middelware somehow?

if(builder.Environment.IsDevelopment())
{
    builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(Program).Assembly).UseReduxDevTools());
}
else
{
    builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(Program).Assembly));
}
mrpmorris commented 2 years ago

Edit your csproj file

    <ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <PackageReference Include="Fluxor.Blazor.Web.ReduxDevTools" ...etc... />
    </ItemGroup>