Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Failed To Load Resource: The Server Responded With A Status Of 401 (Unauthorised)

Asked by Al German Nov 18, 2022 1.2K views 1 answer
Share

About this question

I have Visualforce pages contains Lightning App, that contains Aura components hosted to Community aka Experience Builder, which are working fine when user is loggedIn, however, for guest users it is throwing "Failed to load resource: the server responded with a status of 401 (Unauthorised)" Please find the below code for the VF page and controller class

 [removed] // Here 'VfApp' Is Lightning Application Name $Lightning.use("c:UserActionMenuApp", function () { $Lightning.createComponent("c:horizontalNav", { }, "horizontalNav", function (component) { console.log("component created"); }); }); [removed]  
Code for the Class file
public without sharing class CommunityUserDetailController { @AuraEnabled(cacheable=true) public static List getCurrentUser(){ System.debug('==getCurrentUser CALLED===>'); List users=new List(); if(UserInfo.getUserType()!='Guest'){ users= [SELECT Id, Name, profile.Name,SmallPhotourl,FullPhotoUrl FROM User WHERE Id =: Userinfo.getUserId()]; } System.debug('==getCurrentUser users===>'+ users); return users; } }

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.