Overview

When using the output from Drupal’s JSON:API in a separate application, a CORS error occurred. Here, I explain how to resolve the CORS error.

Solution

Copy the following file:

/web/sites/default/default.services.yml

cp/web/sites/default/default.services.yml/web/sites/default/services.yml

Then, set enabled to true in cors.config:

#C###coonRfNre#afeoosnliart.aSlgdecbpoum:olewrhoneceetrBfdidteyi:fHCpgyersid:fao:neaads/fflles/oaslr-drueosSemlw:ivat#etetd[elitC]oohhhHpneaeTenaTracgdP.boeemonrrouftseztih,qigiultuslelhrisaeatkt.toesotiroot'(gpnrxC/iu-OecieaRns!lS-il)Undo.Siw/gsedeadonb-celhsree/adaWl.de.ebr/'H.TTP/Access_control_CORS

As a result, the CORS error was resolved.

Summary

I hope this serves as a useful reference for anyone experiencing a similar issue.