os.platform() Not Working Correctly In Website - javascript

I'm using the built-in 'os.platform()' function in Node.js to get the home directory of a user when they sign in to a website so they can import files. In order to specify which path to look for those files in, I need to know the OS of the user's PC. When I run the code in my local server, it runs fine, returning "win32". However, when I deploy the website, it always reads "linux", which I can only assume is the operating system of the server. How can I make sure that "os.platform()" returns the client's OS and nothing else?
I should also mention that I am running this code with a console.log(os.platform()) in getInitialProps(). I've tried using navigator, window, and process.env.HOME but none of those have worked for me, as they always return undefined inside of getInitialProps().

Related

Looking for a technology/code in java or other maybe to sync files from browser or https

https://github.com/deanhiller/webpieces is a platform that you can write code in java without rebooting the server via it's DevelopmentServer.
Now, to avoid the cycle of fix code, deploy to cloud, test, fix more code, deploy to cloud to test, I would like to just sync changed files to the cloud container so that the cycle becomes
change code
test
no more deploying and since you are just uploading human changes, it's FAST. Now, webpieces is a webserver that hosts a website or json api or whatever. I am thinking of 2 ways of doing this but not sure the technology is there?
Go to webpage on the cloud server and input local source directories to monitor
Locally, just run a program webpiecesSync configuring source directories and the json api to hit on the cloud instance
Number 2 has an extreme advantage over #1 in that I can register for async file notification of changes so as you change a file, the sync uploads it to the cloud and webpieces DevelopmentServer just saves the file to the needed location and when you hit the webpage with the change, the DevelopmentServer does the work of recompiling when needed.
I am not sure #1 can even come close to #2, but if anyone knows of a technology there, javascript or whatever that could maybe do this, I am wondering if I could make a wizard in the DevelopmentServer sync plugin (if I had one) that would then just keep up to date with changes of the directories and grab those files(assuming the user gives it permission somehow). I am very lost if #1 is even feasible?
Any ideas/guesses greatly appreciated.
thanks,
Dean

React app not rendering on another pc from internet

What's up friends?
I am programming an app using React. The page loads me perfectly from my pc and on my phone using a local ip, if I connect to my public IP from another computer the page goes blank, and apparently it stays in a loop of loading files 0.chunk. js or something similar and never renders the page.
I already configured HOST and IP in the .env file but I still have the same problem.
UPDATE
I dont know why, but deleted and reconfigure .env file and it works

ERR_NAME_NOT_RESOLVED error on running the webapp on localhost

I am trying to run a webapp on Chrome. My index.html gets loaded, however the googleapis and angular js files are not getting imported and on inspecting the error is:
GET https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css net::ERR_NAME_NOT_RESOLVED.
All the local js files are getting loaded, however all cdnjs files and angular js files are not getting loaded. I tried setting nameserver to 8.8.8.8, however the error doesnot get away. Is it some certificate issue? I am running the webapp from localhost. There are other URLS importing angular scripts that are also giving the same error.
To understand this error you have to understand how domain names work.
When your computer goes looking for say "www.cloudfare.com", it doesn't know where that is, so it asks a "DNS server" what the corresponding IP address is for that domain. This is essentially the same idea as an old phone book: you give the DNS servers a name, and you get back a number that you (or at least your computer) can actually use.
In this case, the error you're seeing indicates your computer wasn't able to resolve https://cdnjs.cloudflare.com and find an IP address for it. Most likely this has something to do with your local network. For instance, you might have configured your router to block that domain, or you might have added entry to your /etc/hosts file for that domain, with an invalid IP address.
Unfortunately the ultimate solution depends heavily on your local circumstances: essentially you just have to fix whatever is getting in the way of your computer resolving that domain.

ember build fails after code change

I am trying to run ember locally on my Windows 7 machine
When I load my app for the first time, the ember build is successful and ember serve starts and I can access my app.
However, as soon as I make even a small change in my code and try to refresh, I get the following error;
ENOTEMPTY, directory not empty
'C:\MyCode\myProj\tmp\tree_merger-tmp_dest_dir-cQOjj10S.tmp\modules\ember-validations\validators'
I am using Sublime Text editor and have added the following in Preferences: Settings > User
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "tmp/*"]
While I have seen other solutions like
Disable Windows Search Index for temporary files (Windows does not seem to be already indexing my tmp folder)
Disable Windows Defender for temporary files
Please note I do not have Admin rights on my system (it's a company provided system).
I do have anti-virus running, but cannot disable it.
So kindly suggest any fixes accordingly.

Create ActiveXObject on *server*

I have created a little html stub that allows a user to compare various spellers. I would like to include the Word speller and I have written code in a .js file to create an ActiveXObject thus:
var wordApp = new ActiveXobject("Word.Application");
This works fine on my local machine but I get the dreaded 'Automation server can't create object' error when I try it on other machines. I have searched and read the various articles on the topic and I understand that what I am trying to do is very,very bad, not safe, doesn't work on any browser than IE, and so on. This is for an internal test app in a trusted environment and all I want is for others to be able to access the page and see the result without forcing them to make extreme changes to their security settings.
So, here is my question. Is there a way that I can get this to run server side on my machine running IIS and hosting the website? Ideally I would like to be able to insert my HTML into an aspx file and, when the submit button is pushed, have it either run all the javascript on server side or at least run the portion that calls the activeX code. If this isn't feasible, can I migrate the specific functions that call the activeX and get the data to C# or VB and still run the safer functions in JS?
Thanks for your advice!

Categories

Resources