Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Meteor server-side path to /public?

On the Meteor client-side, I know that files in the project's public directory are referenced at '/'.

How are they referenced on the server-side?

I am trying to get a directory listing with fs.readdir, but I don't know how to construct the path to get to the server side equivalent of the client side '/images/gallery'.

Any advice?

like image 579
Bob Rockefeller Avatar asked Jun 26 '13 19:06

Bob Rockefeller


Video Answer


2 Answers

The accepted "./public/" answer does not work for me in Meteor 1.1.

However, Meteor supplies the server path via the meteor_bootstrap.serverDir variable, so to get the public folder path I use the following line:

path.join(__meteor_bootstrap__.serverDir, "../web.browser/app");

This works on my local Windows machine and on meteor.com.

Note that this is the "running" version of your public folder, so - at least in development, I haven't checked this part in production - it's actually a merge of your development "public" folder and all of your client-side JS files. If you have a "config" folder in your project, and a "config" folder in your public directory, the "running" path will include the contents of both.

like image 168
Ashley Reid Avatar answered Sep 21 '22 13:09

Ashley Reid


there's an upgrade since the 0.6.5 version of meteor, main.js now chdirs into programs/server in your bundle. So the content of the public directory is here : ../client/app/

the detail on github

like image 21
Ronald Pauffert Avatar answered Sep 22 '22 13:09

Ronald Pauffert