diff --git a/templates/web/src/client.ts.twig b/templates/web/src/client.ts.twig index e5c0beb14..7a5be73e1 100644 --- a/templates/web/src/client.ts.twig +++ b/templates/web/src/client.ts.twig @@ -683,6 +683,16 @@ class Client { const response = await fetch(uri, options); + // type opaque: No-CORS, different-origin response (CORS-issue) + if (response.type === 'opaque') { + throw new {{spec.title | caseUcfirst}}Exception( + `Invalid Origin. Register your new client (${window.location.host}) as a new Web platform on your project console dashboard`, + 403, + "forbidden", + "" + ); + } + const warnings = response.headers.get('x-{{ spec.title | lower }}-warning'); if (warnings) { warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));