Skip to content

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

Description

@abbymrs
No description provided.

Activity

  1. vesteraas commented on Oct 21, 2016

    @vesteraas

    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.

  2. orizens commented on Oct 21, 2016

    @orizens
    Contributor

    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

  3. abbymrs commented on Oct 24, 2016

    @abbymrs
    Author

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

  4. abbymrs commented on Oct 26, 2016

    @abbymrs
    Author

    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'
            }
        },
    ....
    
  5. vesteraas commented on Oct 26, 2016

    @vesteraas

    @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

  6. abbymrs commented on Oct 26, 2016

    @abbymrs
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions