C
C#3y ago
Taylor

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
Taylor
TaylorOP3y ago
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.
Taylor
TaylorOP3y ago
And my file paths here
phaseshift
phaseshift3y ago
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.
Taylor
TaylorOP3y ago
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.
phaseshift
phaseshift3y ago
I just did this
phaseshift
phaseshift3y ago
don't forget to /close if your problem is solved 👍
Taylor
TaylorOP3y ago
uhm Wow. I kind of suck at research then. how did you know usestaticfiels was the way to go though
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server