berhir / AspNetCore.SpaYarp

An alternative approach to the new ASP.NET Core SPA templates in .NET 6. It uses YARP as proxy to forward requests to the SPA dev server.
MIT License
99 stars 12 forks source link

Any guideline if index page is a server side Razor page? #13

Closed rmeshksar closed 2 years ago

rmeshksar commented 2 years ago

Hi, In our ASP.NET/Angular application we are not using index.html, rather we do have index.cshtml Razor page and in the program.cs file we have this as very last setting:

app.MapFallbackToController("Index", "Home");

and we add references to the generated JavaScript file hard-coded in the index.cshtml file:

    <script src="~/dist/runtime.js" asp-append-version="true"></script>
    <script src="~/dist/polyfills.js" asp-append-version="true"></script>
    <script src="~/dist/main.js" asp-append-version="true"></script>
    <script src="~/dist/vendor.js" asp-append-version="true"></script>

Still we want to take advantage of hot module reloading the Angular/Webpack provide.

Do you have any recommendation?

berhir commented 2 years ago

Hi, it shouldn't make any difference if you use an index.html file or an index.cshtml file.

If you want to forward only requests starting with a specific path (in your case /dist), you can specify it in your project file: <SpaPublicPath>/dist</SpaPublicPath>. Please take a look at the readme for more details on how to add the configuration.