web-react icon indicating copy to clipboard operation
web-react copied to clipboard

npm run dev prevent api calls

Open allannaranjo opened this issue 10 years ago • 9 comments

I used web-react as a boilerplate, when I build the app (npm run build) and then npm run start the app launches in the port 3000, in the root (http://localhost:3000/) I see the app being rendered and in the same port I can make calls to an api end point I created (GET http://localhost:3000/api/me). However when I do npm run dev, the app loads in the port 8080 and it renders the front end in the root but if I do http://localhost:8080/api/me I get PAGE NOT FOUND. Why is this happening?

Regards

allannaranjo avatar Jan 13 '16 20:01 allannaranjo

Hi, With dev mode there is no nodejs server behind, just a webpack "server" handler. In Readme, look for next section called DEV ONLY CLIENT/SERVER

darul75 avatar Jan 13 '16 20:01 darul75

I did that and it is supposed to start the app in http://localhost:8081 however all I get in the browser is: Cannot GET / for both front end and api calls.

Regards,

On Wed, Jan 13, 2016 at 2:38 PM, Julien Valéry [email protected] wrote:

Hi, With dev mode there is no nodejs server behind, just a webpack "server" handler. In Readme, look for next section called DEV ONLY CLIENT/SERVER

— Reply to this email directly or view it on GitHub https://github.com/darul75/web-react/issues/20#issuecomment-171425590.

allannaranjo avatar Jan 13 '16 21:01 allannaranjo

I have to check tomorrow, but webpack dev server is listening on port 8081 but you node backend server is on 3000. can you try on 127.0.0.1:3000

darul75 avatar Jan 13 '16 21:01 darul75

You need to run 2 process separitly on 2 prompts.

One with command :

npm run dev-server-client

( will run webpack server, rebundle when changes emitted ). Wait for this process to finish its work...about few seconds ;)

Then launch second: npm run dev-server

(starts your backend server)

Sorry on my phone right now

darul75 avatar Jan 13 '16 21:01 darul75

Hi, thanks for replying: npm run dev-server-client twice?

Allan

On Wed, Jan 13, 2016 at 3:38 PM, Julien Valéry [email protected] wrote:

You need to run 2 process separitly on 2 prompts.

One with command :

npm run dev-server-client

( will run webpack server, rebundle when changes emitted ). Wait for this process to finish its work...about few seconds ;)

Then launch second: npm run dev-server-client

(starts your backend server)

Sorry on my phone right now

— Reply to this email directly or view it on GitHub https://github.com/darul75/web-react/issues/20#issuecomment-171442628.

allannaranjo avatar Jan 13 '16 21:01 allannaranjo

I imagine you mean:

npm run dev-server-debug

but I get:

Cannot find module '/**************/build/server.js'

Any idea?

On Wed, Jan 13, 2016 at 3:40 PM, Allan Naranjo [email protected] wrote:

Hi, thanks for replying: npm run dev-server-client twice?

Allan

On Wed, Jan 13, 2016 at 3:38 PM, Julien Valéry [email protected] wrote:

You need to run 2 process separitly on 2 prompts.

One with command :

npm run dev-server-client

( will run webpack server, rebundle when changes emitted ). Wait for this process to finish its work...about few seconds ;)

Then launch second: npm run dev-server-client

(starts your backend server)

Sorry on my phone right now

— Reply to this email directly or view it on GitHub https://github.com/darul75/web-react/issues/20#issuecomment-171442628.

allannaranjo avatar Jan 13 '16 21:01 allannaranjo

I ran npm run build to be able to run "npm run dev-server" however the the build directory only has webpack.records.json and the script in package.json is: "dev-server": "node build/server.js", and since the build directory has no server.js I get:

Cannot find module '/build/server.js'. Any ideas? Regards,

Allan

On Wed, Jan 13, 2016 at 3:43 PM, Allan Naranjo [email protected] wrote:

I imagine you mean:

npm run dev-server-debug

but I get:

Cannot find module '/**************/build/server.js'

Any idea?

On Wed, Jan 13, 2016 at 3:40 PM, Allan Naranjo [email protected] wrote:

Hi, thanks for replying: npm run dev-server-client twice?

Allan

On Wed, Jan 13, 2016 at 3:38 PM, Julien Valéry [email protected] wrote:

You need to run 2 process separitly on 2 prompts.

One with command :

npm run dev-server-client

( will run webpack server, rebundle when changes emitted ). Wait for this process to finish its work...about few seconds ;)

Then launch second: npm run dev-server-client

(starts your backend server)

Sorry on my phone right now

— Reply to this email directly or view it on GitHub https://github.com/darul75/web-react/issues/20#issuecomment-171442628.

allannaranjo avatar Jan 13 '16 21:01 allannaranjo

My issue is that everytime I make a change in the server I have to run, npm run build and then npm run start and it takes forever to do stuff.

On Wed, Jan 13, 2016 at 3:54 PM, Allan Naranjo [email protected] wrote:

I ran npm run build to be able to run "npm run dev-server" however the the build directory only has webpack.records.json and the script in package.json is: "dev-server": "node build/server.js", and since the build directory has no server.js I get:

Cannot find module '/build/server.js'. Any ideas? Regards,

Allan

On Wed, Jan 13, 2016 at 3:43 PM, Allan Naranjo [email protected] wrote:

I imagine you mean:

npm run dev-server-debug

but I get:

Cannot find module '/**************/build/server.js'

Any idea?

On Wed, Jan 13, 2016 at 3:40 PM, Allan Naranjo [email protected] wrote:

Hi, thanks for replying: npm run dev-server-client twice?

Allan

On Wed, Jan 13, 2016 at 3:38 PM, Julien Valéry <[email protected]

wrote:

You need to run 2 process separitly on 2 prompts.

One with command :

npm run dev-server-client

( will run webpack server, rebundle when changes emitted ). Wait for this process to finish its work...about few seconds ;)

Then launch second: npm run dev-server-client

(starts your backend server)

Sorry on my phone right now

— Reply to this email directly or view it on GitHub https://github.com/darul75/web-react/issues/20#issuecomment-171442628 .

allannaranjo avatar Jan 13 '16 22:01 allannaranjo

hi, there was a regression in api.js file when exporting module

https://github.com/darul75/web-react/blob/a9edfb76a863e9ef1c4625a6e3c0558e357ea9bf/server/api/api.js

you can upgrade to 1.2.1 or get this code, it would fine then for hot reloading your changes in some cases, look at how webpack HMR works, for example it won't work for new route in express, that kind of stuff.

darul75 avatar Jan 14 '16 09:01 darul75