C
C#2y 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
Taylor2y 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
Taylor2y ago
And my file paths here
phaseshift
phaseshift2y 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
Taylor2y 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
phaseshift2y ago
I just did this
phaseshift
phaseshift2y ago
don't forget to /close if your problem is solved 👍
Taylor
Taylor2y ago
uhm Wow. I kind of suck at research then. how did you know usestaticfiels was the way to go though
Accord
Accord2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server
More Posts
XAML Objects?In the screenshot does creating something like this label mean that it's creating a nameless object?Could not load file or assembly 'System.Collections.Imutable' when using source generatorsI am trying source generators, and now i am getting warning ```Generator failed to generate source. Generating random numbers (int32) [Answered]As you may know ``Guid.NewGuid()`` returns a 128bit random "number" which is very unlikely to get duVisual Studio doesn't work as expected with source generators [Answered]I wanted to give source generators a try, i followed Microsoft tutorial and everything worked as expBlazor WASM Hosted uses wrong basepath on page reloadHello! I have a web app that mostly works as it should, except on a Page Refresh or direct accessingCalling a static abstract method without a generic type [Answered]If I have this code with a static abstract member `Bar` in the interface `IFoo`, is there *any way* WinUI3 app doesn't run outside of Visual StudioI just tried to share a tool I made in WinUI3 with .NET6. That shouldn't be a problem with the publiLearning Agile and Scrum on my own, looking for advice, resources, insightsI haven't had the chance to work both in groups of developers nor in groups of developers working unProper C multicatch syntaxI saw in Java that you can do multicatch blocks (see image) I also looked it up on stackoverflow: Change output directory of nuget packageUsually, nuget package assemblies and dependencies are copied to OutDir during build, e.g. `bin\Debu