How the Node.js "npm run proxy" command works

Asked

Viewed 182 times

1

I want to do some work on the open source game Codecombat (https://github.com/codecombat/codecombat). I managed to install the game, but in the community (in English) I was recommended to execute the command "npm run proxy" to see the project working in the browser.

When I execute this command and access the address 127.0.0.1:3000 in the browser I am redirected to the production server (https://codecombat.com/). Some developers have said that "the proxy mode means the whole backend is the original, only the frontend is my".

I opened package.json and it has the following content:

  (...)"scripts": {
    "start": "node ./index.js",
    "test": "COCO_TRAVIS_TEST=1 npm run webpack && ./node_modules/.bin/karma start --single-run --reporters dots",
    "test-china": "COCO_CHINA_INFRASTRUCTURE=true npm run test",
    "predeploy": "echo Starting deployment--hold onto your butts.; echo Skipping webpack build --production",
    "postdeploy": "echo Deployed. Unclench.",
    "postinstall": "bower install && node ./runWebpack.js",
    "webpack": "webpack",
    "bower": "bower",
    "dev": "webpack --watch",
    "dev-container": "DEV_CONTAINER=1 webpack --watch",
    "multicore": "coffee multicore.coffee",
    "proxy": "COCO_PROXY='true' nodemon",
    "proxy-win": "cross-env COCO_PROXY='true' nodemon",
    "analyzer": "COCO_ANALYZER_BUNDLE=1 webpack --profile --json > stats.json"
  },(...)

It can be observed that the command proxy has to do with COCO_PROXY (I imagine it’s an environment variable) and the nodemon.

But how does it work? Can someone explain to me how this proxy service works on Node?

  • 3

    Possible duplicate of What the npm build command does?

  • I think not Luiz Felipe, I opened the package.json file of the project, and found this: "scripts": { (...), "proxy": "CO_PROXY='true' nodemon"}. Apparently this PROXY command is related to COCO_PROXY.

  • npm start does not work?

  • "npm start" works Francisco, but I can’t get full access to the platform, the reading material (https://github.com/codecombat/codecombat/wiki/Dev-Setup:-General-Information) recommends "npm run proxy" to gain access to all data from the remote server.

  • COCO_PROXY is an environment variable, the way it is to start in linux by setting the variable, in windows you must use the command set COCO_PROXY = true and then start on the app.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.