Front stack help
I'm doing this exercise to figure out full stack C#.
https://learn.microsoft.com/en-us/training/modules/build-web-api-minimal-spa/5-exercise-create-api
Exercise - Create an API - Training
Create an API.
21 Replies
I'm not sure where I'm suppose to be pasting the proxy property as what I have copied is just localhost:5100
the dev proxy which is what you are looking at is normally configured so your frontend acts as a gateway to your backend during development
this fixes the "problem" that the frontend doesnt have its own hosting during production, but it does at dev time
so normally you'd do something like
api/
-> localhost:5001/api
what is the issue you are having?
with that setup, I'd expect a call to
localhost:3000/pizzas
to hit localhost:5100/
behind the scenesit's suppose to load the front end and display properly
but it jsut keeps loading a white screen
thats not related to your proxy at all
your frontend is being served at
localhost:3000
i meant once i changed
to
it just keeps loading the white screen
hm
can't help but notice it removed the
host: true,
partso i was thinking it's a issue with the proxy server not being set up right
the documentation for vite says that
host: true
tells the server to listen to all interfaces
instead of just localhostthis is what the tutorial says but this is also my first time using C#
this is not related to C# at all so far
its javascript and vite you are having issues with
should i include host:true?
give it a try
i think it worked
but giving weird errors
ill give some stuff a try though
well yeah
its trying to read some json, but your backend isnt running
is my current guess at least
I just set up a brand new frontend + backend to test this out
thats my vite config
(I used solidJS instead of react, but thats the only difference)
and in my frontend, I do
(await fetch("api/test")).json();
that sends a request to the frontend server that matches the proxy pattern and is routed to my backend
here is literally all of my backend code, for reference
(this a super minimal example, dont actually build backends like this :D)
the changeOrigin
turned out to be very important. I also ran my backend in http mode, so I disabled secure
hope this helps @Rice Spicequick question Would you mind going through the tutorial? It hsouldn't take too long since you already work with this @Pobiega
I looked through yours but tbh i have no idea what im looking at ðŸ˜
I would mind yeah :p