fullstackhero / blazor-wasm-boilerplate

Clean Architecture Boilerplate Template for .NET 6.0 Blazor WebAssembly built for FSH WebAPI with the goodness of MudBlazor Components.
https://fullstackhero.net/blazor-webassembly-boilerplate/general/getting-started/
MIT License
528 stars 323 forks source link

Cannot login using administrator credentials #264

Closed Sarmadjavediqbal closed 1 year ago

Sarmadjavediqbal commented 1 year ago

I cannot login using administrator credentials. Following is a screenshot of the error I am getting after trying to login.

image

Sarmadjavediqbal commented 1 year ago

what am I missing? How the web-api and blazor-wasm communicate together???

MikaelHild commented 1 year ago

Have you started both the backend and the frontend project?

Sarmadjavediqbal commented 1 year ago

Have you started both the backend and the frontend project?

Yes I did. both projects were running.

Sarmadjavediqbal commented 1 year ago

Have you started both the backend and the frontend project?

Any solution?? por favor...

MikaelHild commented 1 year ago

What did you see in the log? Could you see that the request was handled by the web-api backend project? The 404 indicates that the blazor app could not find the endpoint.

Sarmadjavediqbal commented 1 year ago

What did you see in the log? Could you see that the request was handled by the web-api backend project? The 404 indicates that the blazor app could not find the endpoint.

You are right. The logger in web-api did not log any event. But I need to know the reason why it is not communicating with the backend. path for blazor is set in CORS in backend. Do I need set path for backend in blazor-wasm ???

MikaelHild commented 1 year ago

You can check if you can access Swagger by this url: localhost:5001/swagger I believe CORS and paths should already be configured.

For simplicity you could also install postman, or if you have it, open the postman collection and test the API.

Sarmadjavediqbal commented 1 year ago

Swagger is running with backend. Do I need to put web-api and blazor-wasm in same solution??

MikaelHild commented 1 year ago

Perfect.

Once the Server is up and running, like any other Blazor application, simply navigate to the Host folder under the source folder of the Blazor Project (\src\Host) and run the following standard commands.

dotnet restore dotnet build dotnet run Once the build process is complete, the application would be reachable by accessing https://localhost:5002 on your browser.

By default, the API Server is set to be running on port 5001 of your local machine. If for some port related reason, you have to run the API on another port or so, navigate to src\Client\wwwroot\appsettings.json of the Blazor Project and change the API Base URL Property and set the value to the port that’s exposing the API. This is the default configuration "ApiBaseUrl": "https://localhost:5001/".

Similarly, the Blazor Project by default is set to run on port 5003 of your local machine. Incase you change this to something else, ensure that you have updated the cors.json configuration file on your API project. This makes sure that there is no CORS related issues while the Blazor project tries to access the API Endpoints.

https://fullstackhero.net/blazor-webassembly-boilerplate/general/getting-started/

Sarmadjavediqbal commented 1 year ago

Perfect.

Once the Server is up and running, like any other Blazor application, simply navigate to the Host folder under the source folder of the Blazor Project (\src\Host) and run the following standard commands.

dotnet restore dotnet build dotnet run Once the build process is complete, the application would be reachable by accessing https://localhost:5002 on your browser.

By default, the API Server is set to be running on port 5001 of your local machine. If for some port related reason, you have to run the API on another port or so, navigate to src\Client\wwwroot\appsettings.json of the Blazor Project and change the API Base URL Property and set the value to the port that’s exposing the API. This is the default configuration "ApiBaseUrl": "https://localhost:5001/".

Similarly, the Blazor Project by default is set to run on port 5003 of your local machine. Incase you change this to something else, ensure that you have updated the cors.json configuration file on your API project. This makes sure that there is no CORS related issues while the Blazor project tries to access the API Endpoints.

https://fullstackhero.net/blazor-webassembly-boilerplate/general/getting-started/

All settings are already set as mentioned. but the frontend is still not communicating with the backend.

MikaelHild commented 1 year ago

Can you check in chrome developer tools what address your Blazor app is trying to call? Developer Tools > Network

Sarmadjavediqbal commented 1 year ago

image

I think it is trying to access default path.

Sarmadjavediqbal commented 1 year ago

How to set custom path in blazor-wasm for web-api???

Sarmadjavediqbal commented 1 year ago

I have set custom route in my web-api as [Route("RootsAdminSvc/v{version:apiVersion}/[controller]")]. Is this the reason why frontend can not authenticate and login????

Sarmadjavediqbal commented 1 year ago

I have set custom route in my web-api as [Route("RootsAdminSvc/v{version:apiVersion}/[controller]")]. Is this the reason why frontend can not authenticate and login????

This was actually the problem. I successfully logged in just by changing the route in FSHApi.cs in Blazor-wasm. Thanks @MikaelHild.