I need to go to a Visualforce page from a Lightning Component. The page has CSRF protection enabled.

I'm trying to use navigateToURL action but it causes the "The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator." error.

    const navigateEvent = $A.get("e.force:navigateToURL");
        "url" : "/apex/TestVisualforceCSRFPage"

How can I direct a user to the Page bypassing the error?

1 Answer 1


Ok, I've found the answer. It's not very beautiful though.

The only way to go from a lightning component to a visualforce page is to use Apex Controller and

Aura.redirect(PageReference pageRef)


Please note, that the Aura.redirect() cannot be covered with unit tests due to "Internal Salesforce.com error" issue. To avoid that I have to use !Test.isRunningTest() workaround.

Hope this will be helpful for someone.

You must log in to answer this question.

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