Meteor: relative/absolute path issue - meteor

I'm testing out some old code and I'm getting an error and it looks like its with these lines of code:
var targetFile='../../../../../public/image1.png';
var sourceFile='../../../../../../game4-dirs/public/image2.png';
fs.writeFileSync(targetFile, fs.readFileSync(sourceFile));
The error I'm getting is:
Error: ENOENT, unlink '../../../../../public/image1.png'
I seem to vaguely remember that public and game4-dirs aren't accessible like this relatively to the product but relatively to where meteor is installed to (or something like that, I can't quite remember).
Has this change in version 1.2.0.2? I was originally using v0.9.3.1
Thank you :)

If your Meteor application lives at myApp on disk then files under myApp/public will be available at root in HTML /. This means the url for image1.png should be simply /image1.png.
It looks like ../../../../../../game4-dirs/public/image2.png is trying to access a file that is not below your meteor app's root directory. Meteor won't allow this on the client for obvious security reasons. If you want to use image2.png you should move it to your app's /public directory and then refer to it in html with simply /image2.png

Related

mrgalaxy:stripe App is not defined

This Meteor web browser site uses the package mrgalaxy:stripe, The first instruction is to
put App.accessRule('https://*.stripe.com/*'); in a client side file mobile-config.js.
Which when done exactly, causes the browser to issue an error:
Uncaught ReferenceError: App is not defined
I looked in Meteor doc but could not figure it out.
Any idea how to fix this? Thanks
You should have that file in the root of your app, not inside your client folder.
From mrgalaxy:stripe documentation:
In order for Stripe.js to be loaded directly on iOS and Android a new rule needs to be created in your mobile-config.js located in the root of your project. Create the new file if it doesn't already exist and insert the line below.
This is necessary for mobile builds to access external URLs. If you're building a mobile app from Meteor, you'll need to add additional configuration info to that mobile-config.js file before deploying. See https://docs.meteor.com/api/mobile-config.html

Trouble initializing less stylesheets on my meteor app

My less style sheets are located in my /public folder for now. I'm trying implement them on my meteor app but to no avail.
This is the error I get:
The stylesheets are located in the /less folder, which is inside the public folder, so the URL should be correct. By the way, all those files that are in the screenshot above are files that import dozens of other variables located deeper in the folder.
I also checked and I have the latest version of less installed. Any help would be appreciated.
The public folder isn't the right place to store the files. Files stored in a “public” folder are served to visitors. These are files like images, favicons, and the “robots.txt” file. So they get served 'as-is', not processed by LESS and served as CSS.
More about Meteor folder conventions.
After discussion in the comments, it seems something is not working right in your less compiler, the less file should not be in the public folder, as already mentioned, and you should not need to include it with a script tag. You can follow these steps to create a new app and test less and see if you can find a difference between this and your current app.
Create a new meteor project
meteor create test
Add less
cd test
meteor add less
Start your server
meteor
add a file sytles.less to the top level folder with this...
.fun {
color: red;
}
Update the test.html file to add the fun class to the text output...
<div class="fun"><p>You've pressed the button {{counter}} times.</p></div>
Load the page, the text should pick up the class and become red. No link to the styles.less file needed. You can try moving it around to different folders, it worked fine from client for me as well. Look around and see what else might be different.
If you still have issues, try providing more information on how the project is set up.

Meteor private directory files not accessible

Within my meteor app I've created a private directory.
With meteor v. <0.9 the files in that directory have been available in '.meteor/local/build/programs/server/assets/app'
However now, using Meteor 0.9.2, the files are not there and I also can't access them via 'Assets.'
Does anyone have an idea what could be the problem?
I found the solution...whenever there is no JavaScript file present in the root folder of the meteor project, meteor somehow doesn't make the private files accessible (all my code is inside subfolders and packages). I solved the issue by adding an empty main.js file to the root folder, and voilà...the files can be accessed. I tried this across several projects and that really seems to be the issue. Very weird behavior indeed, since it doesn't even give me an error message.
I am taking a JSON file from the private directory, parsing the data and then inserting it into a collection on meteor startup. The JSON file is called categories.json with the file structure being /private/categories.json . The parsing and inserting code is below:
var data = JSON.parse(Assets.getText('categories.json'));
for (var i in data) {
Categories.insert({name:data[i].name});
}

changing ROOT_URL for meteor app

I am trying to get my app to run behind an NGINX reverse proxy and had some minor success.
the path is http://dev.sertal.ch/myApp and the application is accessible.
The issue I am still facing is that the images in the public folder are not accessible without hard coding myApp at the start of the URL. This is especially an issue for URLs inside the CSS.
You would want to set the ROOT_URL environment variable when you start your meteor app. If you are using meteor to start from the command line in your app's directory it would be like this:
ROOT_URL=http://dev.sertal.ch/myApp meteor
Meteor has a ROOT_URL property which you must explicitly set for your bundled applications.
It is in the form of Meteor.absoluteUrl([path], [options]) and the path argument is exactly what you're looking for, excerpt from the docs:
A path to append to the root URL. Do not include a leading "/".
Check here for details on options http://docs.meteor.com/#/full/meteor_absoluteurl

Get Static referenced files with http request in meteor

This can be a silly question but I have had some issues with it. I am trying to implement jwplayer with meteor. Jwplayer will try to get a file based off the url you suggest. So I tried to place a file in localhost:3000/test.mp3. When I tried to hit that url I get just the default site. This would work if I used tomcat. Is there something I can do to get the files relative to meteor directory?
Thanks for your help.
In the /public directory, per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
Meteor hasn't yet implemented server side routing and all directories are ultimately flattened. So for the time being, you can access your file at http://localhost:3000/test.mp3, but that may change in the future.

Resources