Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback-file doesn't work with Blazor webassembly #149

Open
pekspro opened this issue May 12, 2024 · 3 comments · May be fixed by #150
Open

fallback-file doesn't work with Blazor webassembly #149

pekspro opened this issue May 12, 2024 · 3 comments · May be fixed by #150
Labels

Comments

@pekspro
Copy link

pekspro commented May 12, 2024

Describe the bug
I'm trying to use fallback-file with a Blazor webassembly application. I get 404 when I'm loading URL:s that should return the fallback page.

This is related to #104.

To Reproduce
Steps to reproduce the behavior:

Create, publish and host a Blazor Webassembly application like this:

dotnet new create blazorwasm
dotnet publish
dotnet serve --port 5200 --directory bin/Release/net8.0/publish/wwwroot --fallback-file "bin/Release/net8.0/publish/wwwroot/index.html"

Navigate to http://localhost:5200/ and click on counter page. This works fine.

Now, navigate to http://localhost:5200/counter. 404 is returned, but the content in index.html was expected.

Logs

Starting server, serving bin\Release\net8.0\publish\wwwroot
Listening on:
  http://localhost:5200

Press CTRL+C to exit
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5200/counter - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost:5200/counter - - - 404 - text/html 10.6292ms
@pekspro pekspro added the bug label May 12, 2024
@pekspro
Copy link
Author

pekspro commented May 12, 2024

I'm playing with the code and I think the correct way to the application should be:

dotnet serve --port 5200 --directory bin/Release/net8.0/publish/wwwroot --fallback-file index.html

But this will give me an error saying that index.html doesn't exists. I guess it looks in the current directory, not in the directory provided by the directory argument. Everything works if I remove the [FileExists] attribute on the FallbackFile property.

@pekspro pekspro linked a pull request May 12, 2024 that will close this issue
@natemcmaster
Copy link
Owner

natemcmaster commented May 19, 2024

@pekspro
Copy link
Author

pekspro commented May 19, 2024

@natemcmaster, no, that is not necessary. It already uses works as it is :-) MapFallbackToFile is relative to the directory that is hosted as I understand it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants