How to call backend on an aurelia-cli generated app

HI all,

I am new to Aurelia, and I notice that when I type “au run” the aurelia app runs on its own local server at port 8080. However, I have my backend server already running on a separate node process at por 3000. I know that in production, the client files will be server from the same server so there shouldn’t be a problem, however, it seems like too much hassle to build for production just to test if my AJAX requests are working? In other frameworks (create-react-app, for example), it is possible to set up a proxy to redirect requests from one server to the other. Is there something similar in Aurelia-cli?

2 Likes

We don’t have proxy setup offered right now. I agree we need the setup plus doc.

Webpack dev server should have some proxy feature, you probably can find in webpack doc.

For cli built-in bundler, the setup uses browsersync as the dev server. It supports generic nodejs middleware such as proxy.

Here is an example how I use proxy in an app with cli built-in bundler. https://stackoverflow.com/a/51182721/1375096

2 Likes

With regards to webpack here is a description about proxying requests for your backend “Proxying an external API with Webpack: Serve code and a RESTful data from separate endpoints.” von Gene Conroy-Jones https://link.medium.com/VA7G6HP9i1

2 Likes

Thanks, I will try these out. I believe create-react-app’s proxy also uses the http-proxy-middleware npm module internally.

1 Like