-
-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Currently we use __dirname (which returns the path of server.js) as starting point in finding our way to /public.
| const root = path.normalize(`${__dirname}/../..`); |
| app.use(Express.static(`${root}/public`)); |
There are two issues with this scenario:
- It doesn't work after we've compiled the source (in the resulting
/dist,/publicis just one directory up fromserver.js, not two) - The path is not OS-agnostic
I propose a solution that uses process.cwd() instead. Given that we launch the process from /, it's an easy task to find /public:
app.use(Express.static(path.join(process.cwd(), "public")));This works well both with in dev and production and is OS-agnostic as we compile the path using path.join(). Furthermore, in combination with #61, the const root can be entirely removed as it's not used anymore.
Let me know if I should prepare the PR for this one too.
Metadata
Metadata
Assignees
Labels
No labels