question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

connection.identity() failing due to strict MIME type checking

See original GitHub issue

First of all, thank you so much for a library that’s a pleasure to use! The documentation makes this the nicest option for working with Salesforce that I’ve seen.

I currently have a React/Electron app that has been working great for half a year and I haven’t made any code changes for the past month. Last week I started getting the following error when making an identity() call after successfully logging in:

Refused to execute script from 'https://login.salesforce.com/id/...&callback=_jsforce_jsonpCallback_1' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

followed by:

JSONP call time out.

I’ve been using jsforce 1.7.1 this entire time and have made no code changes recently so I’m suspecting Salesforce has subtly changed some behavior that I’m unaware of. The response from the identity() call contains the X-Content-Type-Options: nosniff header so the error makes sense. I just don’t know if this is new behavior and why it’s breaking now. If this is new Salesforce behavior it may be causing unexpected headaches for jsforce.

Adding jsforce-ajax-proxy and configuring the proxyUrl option doesn’t seem to remedy this issue since jsforce is making direct calls to Salesforce for identity().

Here’s the simplest code snippet that reproduces the error:

var conn = new Connection({
  proxyUrl: 'http://localhost:3030/proxy/',
  loginUrl: 'https://login.salesforce.com'
});

conn.login(username, password, function(err) {
  conn.identity(function(err, res) {
    if (err) return console.error(err);
    console.log('never gets here');
  });
});

The proxy is identical to the middleware example you’ve provided here (again, thank you for your wonderful documentation!): https://github.com/jsforce/jsforce-ajax-proxy

I’m out of ideas and I would like to continue using jsforce if at all possible. Any assistance is greatly appreciated!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

3reactions
githubbob42commented, May 17, 2017

I’m experiencing the same thing too. In fact, if you click the “Run” button for the “Identity” method on the Docs page (https://jsforce.github.io/document/#identity), it returns the same error:

Error: JSONP call time out.
    at https://cdnjs.cloudflare.com/ajax/libs/jsforce/1.7.0/jsforce.min.js:2:5873
1reaction
pixel9commented, May 17, 2017

@edwinabt One way to get around this is to not use JSONP but that requires a change in jsforce. I have a branch that disables JSONP support within an Electron environment, but this obviously won’t fix the native browser behavior.

It seems using JSONP was a deliberate change to support Visual Force pages (https://github.com/jsforce/jsforce/pull/375). It’s unfortunate that it breaks normal usage in a browser environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refused to execute script, strict MIME type checking is enabled?
On Windows, it uses data from the registry, so if the "Content Type" value in HKCR/.js is not set to the proper MIME...
Read more >
Why is “strict MIME type checking” blocking the static serving ...
Actually that's not the reason. The answer is that the browser error message is wrong both in Chrome and Firefox.
Read more >
MIME types (IANA media types) - HTTP - MDN Web Docs
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, ......
Read more >
Upload MIME type restriction (instance security hardening)
Use the glide.security.file.mime_type.validation property to activate MIME type checking for uploads. You can enable (set the property to ...
Read more >
Chrome Enterprise and Education release notes
Access to WebHID API from extension service workers in Chrome 110, ✓ ... Strict MIME type checks for Worker scripts, ✓.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found