Why is react .net core not serving my SPA files?? [Answered]
I have been trying to do a very simple thing for a very long time and could really use some help. I have a react app that is compiled and ready to go. If I were to access it at a certain URL on my server, it would work as a standalone project. To make deployments easier I wanted to start including it with its API project written in C#. My god. What a frustrating disaster.
What I want SHOULD be easy.
When request path starts with "/demo", show this SPA.
When request path starts with "/api", show the API.
Whene deployed, the entire app will be at /projects/pixelstacker/. So the HTML and JS all reference paths like, "/projects/pixelstacker/demo/assets/css/somefoo.css"
But in the c# side the request path would look like "/demo/assets/css/somefoo.css" thanks to how nginx does its proxying.
Please help.
8 Replies
Note my super confused code heerrre. https://pastebin.com/DLBDLUi8
Pastebin
Current startup.cs code - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
And my file paths here
Have you read https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-6.0#serve-files-outside-of-web-root
Static files in ASP.NET Core
Learn how to serve and secure static files and configure static file hosting middleware behaviors in an ASP.NET Core web app.
I have not
Lemme read
@phaseshift was that supposed to be easy to find? How did you find the exact fix so easily?
That actually is exactly what I want, and so much easier than all the other guides I looked at.
I just did this
don't forget to
/close
if your problem is solved 👍uhm
Wow. I kind of suck at research then.
how did you know usestaticfiels was the way to go though
✅ This post has been marked as answered!