Skip to content

Tag: express

Send Image from subdomain Express.js

Lets say I have this for local testing. This gets a file based on a path to the file of course. Now lets say that the img folder is actually the folder to the subdomain, and I wanted to send the image from the subdomain itself, so instead of the api requesting to the main site aka mysite.com, it would

Unable to get __dirname value

I am using __dirname to get absolute path to GraphQL schema: I have changed module to fit ES6 module standard and __dirname now is undefined. How can I resolve path to schema? Answer There is some issue with esm + __dirname https://nodejs.org/api/esm.html#esm_no_require_exports_module_exports_filename_dirname…

Is this bad practice for res.locals? (Node.js, express)

I was wondering if using res.locals like in this code example is bad practice or if there can occur any problems if you use it this way: Basically I: I verify the session-cookie in app.use (Im using firebase auth) I set the res.locals.userId = userId And then use the local i just set in the app.get (I need to…