Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add NodeJS to the project? we use nodejs for backend. Someone can help? #1119

Closed
abbymrs opened this issue Oct 21, 2016 · 6 comments
Closed

Comments

@abbymrs
Copy link

abbymrs commented Oct 21, 2016

No description provided.

@vesteraas
Copy link

vesteraas commented Oct 21, 2016

You could add the proxy parameter to devServer in webpack.dev.js:

        devServer: {
            proxy: {
                '/api/*': 'http://<YOUR_BACKEND_HOST>:<YOUR_BACKEND_PORT>',
            },
            ...
        },

This way, all requests starting with '/api/' will be proxied to your backend server.

@orizens
Copy link
Contributor

orizens commented Oct 21, 2016

if you want to run the webpack through a nodejs file as a start, have a look at this:
https://github.com/orizens/echoes/blob/feature/node-server/server.js

@abbymrs
Copy link
Author

abbymrs commented Oct 24, 2016

@vesteraas, thanks.
I fixed it with your method.

@abbymrs abbymrs closed this as completed Oct 24, 2016
@abbymrs
Copy link
Author

abbymrs commented Oct 26, 2016

Hi @vesteraas ,
i need your further help....
with the config as below, angular2.0.0 project works with node as backend, but it failed in angular1.5 project, may i know where it was wrong?

....
 devServer: {
        port: 5000,
        host: 'localhost',
        historyApiFallback: true,
        watchOptions: {
            aggregateTimeout: 300,
            poll: 1000
        },
        outputPath: '/',
        proxy: {
            '/api/*': 'http://localhost:8000'
        }
    },
....

@vesteraas
Copy link

vesteraas commented Oct 26, 2016

@abbymrs I guess your question is off-topic here (as well as my answer) but have a look at http://stackoverflow.com/questions/35538472/webpack-dev-server-with-backend-api

@abbymrs
Copy link
Author

abbymrs commented Oct 26, 2016

thanks, i rechecked again, it was my mistake that forgot to add '/api/' in my front end codes when make requests from backend.
Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants