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.

No Access-Control-Allow-Origin header is present message on bulk API response via Visualforce page

See original GitHub issue

I have a Visualforce page that I am using to bulk upload records from a csv file. In using the JSforce framework, I am creating my connection like this:

var conn = new jsforce.Connection({ 
                    accessToken: '{!$Api.Session_Id}',
                    serverUrl: 'https://cs7.salesforce.com',
                    proxyUrl: '/services/proxy'
                });

This org also has the My Domain option configured, and I have tried setting the serverUrl with the custom domain name as well. I am able to create a job, and batches, and execute them, but when the “onresponse” event fires, I start getting this error message:

XMLHttpRequest cannot load https://mydomain--demo.cs7.my.salesforce.com/_ui/common/request/servlet/JsLoggingServlet. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://mydomain--demo--c.cs7.visual.force.com’ is therefore not allowed access.

In my current codebase, I am creating the job manually:

var job = conn.bulk.createJob('SMBulk__c','insert');

And adding the batches to that job:

var batch = job.createBatch();
batch.execute(subfile);

I have also tried this using the bulk load method as well:

conn.bulk.load("SMBulk__c","insert",subfile,
                                     function(err,rets){});

Any help or advice would be greatly appreciated!! Jim

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
stomitacommented, Feb 16, 2015

I was wrong. It still needs proxyUrl when using bulk API, surely it accepts bulk API request but it redirects to other domain than Visualforce page. I think @jimrae 's last setting is the one how to connect to bulk API from Visualforce page.

conn = new jsforce.Connection({ 
    accessToken: '{!$Api.Session_Id}',
    proxyUrl: '/services/proxy'
});
0reactions
jimraecommented, Feb 16, 2015

Thank you for the validation. That is the way I ended up setting up the configuration for my project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm facing CORS policy: No 'Access-Control-Allow-Origin ...
I'm facing CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Read more >
Getting No 'Access-Control-Allow-Origin' header is present on ...
The origins are different; your request is to https, and the origin is http. Are you able to access the site through https?...
Read more >
Bulk API 2.0 and Bulk API Developer Guide
The REST-based Bulk API 2.0 provides a programmatic option to asynchronously upload, query, or delete large data sets in your Salesforce.
Read more >
No 'Access-Control-Allow-Origin' header is present on the ...
I keep getting this error message: Fetch API cannot load . Response to preflight request doesn't pass access control check: No 'Access-Control- ......
Read more >
Cross-origin resource sharing (CORS) | Cloud Storage
If they don't match, or if the Access-Control-Allow-Origin header is not present in the response, the request fails. A preflighted request performs the ......
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