I'm unable to replicate that problem, @MattBunch. Using Safari, I uploaded an html file to the /files area of my course and added a link to it within the Rich Content Editor using the Course Link option. Canvas treats it like a file and opens the file preview showing the content of the file.
You mention a .js file. Canvas does not allow any <script> elements to be added to the HTML view of the Rich Content Editor, and it's possible that would present the error you describe. Another option is to use an <iframe> to make the page content appear within the Rich Content Editor.
If you're not using <script>, check to confirm that the link begins with https:// instead of http://. Browsers do not like to display http:// webpages inside an https:// webpage because that's an easy way for security violations to spread.