[SalesForce] Accessing Visualforce static resources from local machine

FINAL UPDATE:

just in-case if anybody else is looking the error message solution which I was getting is due to the fact that: When you get a share link, the link points to a web page that displays the content. To get the raw content, use ?raw=1
See https://www.dropbox.com/help/201.

so I end-up adding ?raw=1 in the url and its working fine

Hope this will help others

EDIT 2:

in VFP page I have:

<script type='text/javascript' src='https://www.dropbox.com/....'>

and tried this both get the same error message

<script src='https://www.dropbox.com/.....'>

error:

Refused to execute script from
'https://www.dropbox.com/…' because
its MIME type ('text/html') is not executable, and strict MIME type
checking is enabled.

EDIT:

The other option I have tried is uploading the JS file to on the web site and try accessing it from the VFP and I see that I'm getting error:

VFP:

<script type='text/javascript' src='http://****/js/myjavscript.js'>

Error:

'http://****/js/myjavscript.js'. This request has been blocked; the
content must be served over HTTPS.

So far, I have seen all the examples that related with uploading your resource then accessing but is that possible to have a reference on your local machine and access the resources? in my particular example I'm working with JS file that constantly needs to do changes till the development is done, I'm looking a way to make changes to JS file locally and still easily able to access in VFP

Best Answer

As a workaround, you can host non-sensitive JS files on a file host such as Dropbox, save the JS files in your synched folder, and link to them from your VF file with their public link.

enter image description here

enter image description here

When you save the JS file locally, your changes will automatically be synched to the online versions and will update your Visualforce page.

I've used this approach when working on JS applications before, and it works great. The links support HTTPS, so they should be fine for your use case.

See the Dropbox documentation for more information on linking to hosted files.

Related Topic