Unable to access Javascript outside Rails aplication - javascript

We have a JS file which is accessed by different applications.
These applications able to access the JS from our staging application deployed Heroku(e.g, https://xyx.herokuapp.com/assets/businesses/affiliate/affiliate.js) but are not able access file(e.g., https://ourlivesite.com/assets/businesses/affiliate/advowire_affiliate.js from Production deployed on Digital Ocean.
It seem related to asset precompile but could not figureout the issue.
Can anybody help us to identify what could be the problem?

This JS file doesn't depend on any other JS. So We just placed that JS file into public directory.
ADDED
This is temporary solution as when asset precompiles, all the assets under public/asset would be wiped out and generated again

Related

Giving Netlify access to a file hidden by .gitignore on Github

I'm running into a bit of a dilemma with a repository in Github when I try to host the project on Netlify. The project includes a file named config.js and is referenced on both HTML pages. It includes some variables and a function to store my Google Maps API key, so I created a .gitignore file to hide it in my Github repository. The problem is, now that I've deployed it in Netlify, I'm not sure how to reference the config.js as an environment variable or something similar so that Netlify is able to find my Google Maps API key when it renders the site. Right now, the site renders, but it doesn't quite work because I'm running into errors since Netlify cannot see my config.js file.
You'll see my file structure below including the .gitignore command and my config.js that stores the Google Maps API key with the following variables and function calls:
let head = document.getElementsByTagName("head").item(0);
let script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute(
"src",
"<MY GOOGLE MAPS API KEY>"
);
head.appendChild(script);
My question is, how do I go about referencing the variables above that store my API key in an environment variable on Netlify? Or, is there a way to give only Netlify access to the config.js file without exposing it in Github?
There's some documentation on Netlify about deploy keys and submodules, but I don't understand that part of the docs and I'm not sure if they're even relevant to my problem.
You can add variables that you want to be included as part of your static site to Netlify's environment variables, as you've mentioned. That keeps them out of the Git repository.
The tricky part is getting those variables out of the Netlify build environment and into your source code. You have at least two different options, depending on how sensitive your variables are:
If you don't want your variables to be checked into Git but you are OK having them embedded into your public Javascript/HTML files (Google Maps API key might fall into this category), you can use a build tool like Webpack to inject environment variables into your source code. If you're using React or another framework, they usually have ways to include environment variables from the build environment. If you aren't, you may just need to write a custom build script or leverage a pre-built NPM package to inject a small <script>var myVar = "<myEnvironmentVariableValue>";</script> into your HTML page on build. Actually it looks like Netlify can inject some custom script into your page. Maybe you could try that.
If your variables are more sensitive and you don't want them publicly exposed, you need to add an actual server-side component. This could be as fancy as a serverless API or a standard humdrum web server. Then when your front-end needs this secret variable, it reaches out to the server and asks for it, presumably from within an authenticated portion of your website. That keeps the variables out of the public HTML/JS but still lets your site access them on demand.

App to access file system and run in browser

I am willing to make a portable app using HTML CSS JS and similar languages that doesn't need any installation and can be accessed via a browser.
The app should be able to access the file system and create, write and delete files.
The required files will be on the local machine.
I have tried
Applets but the performance is too inconsistent and depends on browsers.
I have also tried using electron but the end result needs installation (correct me if I am wrong)
I am open to all suggestions
Electron's apps can be portable. Copy the electron build resulted folder into a pendrive and execute the main .exe file from there. Everything should work

Angular JS with HANA

I have been trying to run a Angular JS application which is located in HANA. Since the Web IDE does not support Angular JS development, I have the application in Webstorm editor locally in my laptop.I am using a Resource override plug in to direct the location of my files towards local files. However when I run the index.html from the HANA server, I am getting HTTP 404 error.
Please verify that you have two files in the folder to allow web access:
.xsaccess see content guide here
.xsapp (empty file)

How autocopy (on each save action) file in Intellij Idea to other directory?

I have java project with html/js files. These files are packaged by maven and deployed to Java EE application server.
To modify one symbol I (theoretically) need to recompile, repackage and redeploy whole project. In practice change html/js in Intellij Idea project and copy them directly to application server manually.
May be Idea support automatically coping files on save action?
If you use IDEA Ultimate (paid) edition, it supports creating Run/Debug configurations for application servers.
This allows you to create, deploy your application and test/debug within IDEA, without building with Maven.
For example, if you use Tomcat:
Once you launch this configuration, you'll get a convenient redeploy button.

Problems with public directory when deploying Node.js app with Heroku

I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?
Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder.
That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)
More info here: https://devcenter.heroku.com/articles/read-only-filesystem

Categories

Resources