C
C#•8mo ago
M B V R K

How to redirect Angular requests to ASP.NET Core backend host

Hi guys, I'm working on a project using Microservices. One of the services called FrontEndService.WEB, it is a ASP.NET Core Angular project. The general idea about the project it is that the project is a URL Shortener. In that service, exactly in the Angular part, I have a page which the user enter then write the URL then the app shorten the url perfectly, at this point everything working fine. The issue : The Asp.net core backend working on this host https://localhost:7166/ and the Angular frontend working on the https://localhost:44482/ host (they're both on the same project) The real-issue here is I want for example after shorten an url for example https://github.com/MbarkT3STO to be https://localhost:44482/udRMtM2o, now I want every request to that shortened url to redirect the user to https://localhost:7166/udRMtM2o where localhost:7166 is the host of the ASP.NET Core backend. I hope that I well cleared my idea and issue. So, please is there any way to configure the Angular part to automatically redirect any localhost:44482/shortCode to localhost:7166/shortCode??? of course except the home shortening page on localhost:44482/Shorten Please if you have any idea to solve this issue share it with me and massive thanks in advance <3
17 Replies
Pobiega
Pobiega•8mo ago
yeah you'd use a proxy in your frontend vite has this built in these days https://vitejs.dev/config/server-options#server-proxy
M B V R K
M B V R KOP•8mo ago
Is it a Library that can be added to the Angular part or it is a JS framework like Angular?? Because I heard about it but I never worked with it
Pobiega
Pobiega•8mo ago
neither its a build tool it builds and runs your project during development
M B V R K
M B V R KOP•8mo ago
omg another tool to learn :(
Pobiega
Pobiega•8mo ago
I mean, what are you currently using? please dont say webpack :d
M B V R K
M B V R KOP•8mo ago
For building ??
M B V R K
M B V R KOP•8mo ago
I'm a bit scared of shooting on me if I said that I never worked before with a build tool
Pobiega
Pobiega•8mo ago
apparently angular has its own built in thing but it supports vite no build tool? how.. uh.. what? :d
M B V R K
M B V R KOP•8mo ago
I mean I never used any 3rd party build tool when I work on a project I use the built-in tool Shit, I need to learn more
Pobiega
Pobiega•8mo ago
I've never worked with angular, so dont know how that goes but with vue and react, vite is the standard these days svelte too
M B V R K
M B V R KOP•8mo ago
Quick out of topic question please, How long you're working with React ?
Pobiega
Pobiega•8mo ago
0 seconds Im not a frontend dev
M B V R K
M B V R KOP•8mo ago
like me, damn the fron-end is a hell for us
Pobiega
Pobiega•8mo ago
Like, I've used react, solidjs, svelte and vue privately for tiny projects. dont feel comfortable using either vue is what we use at work, so I know that a little bit more, but still very little, I'm a backend dev 🙂
JaimeReynoso
JaimeReynoso•8mo ago
Use a http interceptor in angular https://angular.io/guide/http-interceptor-use-cases
Want results from more Discord servers?
Add your server