-
Notifications
You must be signed in to change notification settings - Fork 156
Description
I put this question on stackoverflow, but there is no-movement at all there... so putting it here also.
I have a project made with dvajs using dva-cli. All my frontend is there, together with roadhogjs just like dva-cli installs.
Then I have a backend project made with a typical express and nodejs configuration. This backend has no webpages, only api calls using the port 3000.
The frontend has a proxy in the webpack config to bypass roadhog mock to localhost:3000 to make the calls to the backend instead of using the mock:
proxy: {
"/api": {
//"target": "http://46540a8f.ngrok.io",
"target": "http://localhost:3000",
"changeOrigin": true,
"pathRewrite": { "^/" : "" }
},
hash: true,
},
So when I make a call like:
return request('/api/users/login', {
method: 'POST',
body: params,
});
The application will call localhost:3000/api/users/login
This configuration is kinda smelly for production, I feel it cand be done more correctly, and I've been trying to find what is the proper configuration to put both projects together.
I was wondering what is the correct configuration for this, if I can put everything in one project (how) or should I use two like now.
In the case of using two, ¿What is the best way of making the api calls? And how do I deploy it? my hosting provider is telling me to upload the backend as the root project and then put the entire frontend in the public folder of the backend project, but I don't like that so much either.