I am trying to use VF remoting in a public site and get the error 'Visualforce Remoting Exception: Error parsing json response: 'Unexpected token <'. Logged in?' when viewing page from a public site guest user context. The remoting is being used by a jquery autocomplete component.

If I test the page from a non-url redirected, sys admin perspective it works as expected.

The site does use URL rewrites, and the site guest user profile has access to all information being searched in the database. It seems to be an authentication issue? If anyone has seen anything like this and has any suggestions re resolution they'd be most appreciated. Im stuck!

Cheers, CH

2 Answers 2


Ok - looks like someone else sorted this and I just stumbled onto their great response.

The issue lies in the url rewriter class, and the mapping from an external 'pretty' url to an internal url with '/apex/' in it makes SF decide it needs to be logged in whilst accessing the remoting logic.

Thus, when the VF remoting request is made we need to ignore it and let it pass unchanged. Per the great solution writeup at following link,you check the inbound url for contains 'apexremote' as indicator of whether to exclude from mapping logic.

See https://developer.salesforce.com/forums/ForumsMain?id=906F000000099DOIAY for more details.

  • I know it's too early right now, but remember you can mark this as the accepted answer in a day or two!
    – Matt Lacey
    Commented Jan 15, 2014 at 2:03
  • So this definitely fixes the issue, by returning the PageReference of '../Your_VF_Page'. However, I had an org where only '/Your_VF_Page' was allowed and didn't cause any errors. Could this be related to some DNS issues on how the SITE is configured? Because to me, adding the '..' in front of the page seems like a workaround instead of a fix (although it does work!) Commented Jul 18, 2018 at 18:22

It looks like the Visualforce Remoting problem was to do with URL rewriting, but it's worth knowing you can create a public REST web service to do the same thing.

  • interesting thanks @metadaddy! I will try the url rewriting fix first and then if it fails looks like Im going to be writing REST... :) Commented Jan 14, 2014 at 8:00
  • Interested to know if it works!
    – metadaddy
    Commented Jan 14, 2014 at 8:24
  • 1
    @metadaddy - I'm using Visualforce remoting in a public Force.com site (as per the OP) to both retrieve and update records without problems. Are you referring to web sites external to Salesforce perchance? Commented Jan 14, 2014 at 8:31
  • 1
    @metadaddy works for me :P fflib-ext-common-developer-edition.na11.force.com Commented Jan 14, 2014 at 11:36
  • 1
    Well, I learn something new every day - that'll teach me to make unfounded assumptions! Edited my answer!
    – metadaddy
    Commented Jan 15, 2014 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .