#Using @astrojs/node adapter with `astro dev`?
1 messages · Page 1 of 1 (latest)
Or maybe I can just skip Express middleware and use src/middleware.js Astro built-in middleware. Or maybe I just need to put Astro on standalone and fetch a separated Express server on another port? But it would be cool to directly work with middleware mode.
Sorry for the ping @serene portal but I read your example and don't know if this is possible.
no issues, for things with specific relevance it's fine to ping me. So as far as I know, the only thing that does not work is when calling an Astro handler from express, the express part is what cannot be live tracked in dev mode, but you still can have the Astro pages in dev mode.
Of course using stand alone or Astro own middleware help here but then it's not express anymore, so what's more important dev or prod ?
In my usecase, the express part gets stable enough so that I don't need to be testing it all the time.
I don't understand, so astro dev with middleware mode using Express will serve with Express? Cause I tried to get a local set in a Express middleware and it was empty. I missed a step?
no, in short in Astro dev, no express involved, only the pages are in dev then.
Also when you are using the middleware mode and Express, you run astro dev AND node ./yourserverentrypoint.js?
I am just trying to understand how to combo it correctly
Not sure about what & how run all the stuff together
hmm, no, only only one or the other, and only astro dev gives a live dev experience, while node entry.js require a run loop ( rerun after every change)
Okok, so if I have a specific need applied with Express, I must build every time to test? (imagine a route needing some Express middlewares)
It also means that some pages would necessarily break when only using astro dev to play with the new toolbar?
BUT everything should work even with astro dev when using the standalone mode, right?
The solution might be to change the mode if in dev mode or production and maybe try to mock missing Express part when using astro dev?
that's a good idea
I always had low interference between express and Astro so did not need them both, and when I did, e.g. a proxy with express for astro I could run both express and dev at the same time but chosing specific ports.
When you say "build" the advantage of node.js is that it does not build, it's a ready to run script that you just save and run, the dev mode only adds a watch for astro files and a hot module reload from vite.
Some people have tried to watch express files and relaunch on save, I just did not try that, was not bothered in my use case.
Having your Astro running in multiple configurations with e.g. an environment variable might be a good idea.
I need to do some testing I guess, maybe try to throw Express if the JavaScript runtime server of Astro is enough, to still benefit from astro dev without breaking some pages (since no more additional routes handled by Express)