1

I'm getting below error when I'm trying to add data using local development: POST http://localhost:3333/webruntime/api/apex/execute 500 (Internal Server Error).

In Network tab in Preview I see also: message:"error parsing or finding aura config: window.Aura not found"

PS: I'm using scratch org.

Js file:

import { LightningElement } from 'lwc';

export default class FlashcardManager extends LightningElement {
    flashcards = [];
    englishWord;
    polishWord;

    handleChange(event) {
        const { name, value } = event.target;

        if (name === "englishWord") {
            this.englishWord = value;

        } else if (name === "polishWord") {
            this.polishWord = value;
        }
    }

    addFlashcardHanlder() {
        const flashcard = {
          polishword: this.polishWord,
          englishWord: this.englishWord
        };
      
        addFlashcard({ payload: JSON.stringify(flashcard) })
          .then(result => {
            if (result) {
              console.log("Added flashcard");
            }
          })
          .catch(error => {
            console.log("Error in adding flashcard: ", error);
          });
      }
      
}

Cls file:

public with sharing class FlashcardController {
  public FlashcardController() {
  }

  @AuraEnabled
  public static string addFlashcard(String payload) {
    try {
      Flashcard payloadObject = (Flashcard) JSON.deserialize(
        payload,
        Flashcard.class
      );
      SObject flashcard = (SObject) Type.forName('Flashcard__c').newInstance();
      flashcard.put('English_word__c', payloadObject.englishWord);
      flashcard.put('Polish_word__c', payloadObject.polishWord);

      insert flashcard;

      return String.valueOf(flashcard.Id);
    } catch (Exception e) {
      throw new AuraHandledException(e.getMessage());
    }
  }
  
  public class Flashcard {
    @AuraEnabled
    public String flashcardId;
    @AuraEnabled
    public String englishWord;
    @AuraEnabled
    public String polishWord;
  }  
}

Can anyone help me with this?

Should I repair local development somehow? Should I add some configurations?

1 Answer 1

0

Something changed about Lightning Out in Summer 23. Deactivating the release update "Security Enhancements for CSRF Tokens for Lightning Apps" resolved the issue for me. (Original answer)

Disable Security Enhancements for CSRF Tokens for Lightning Apps Update

You might need to run npm install on your project to make sure that all the packages are properly installed.

You must log in to answer this question.

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