Urgent.News

What's breaking now, across thousands of outlets.

Tech

Fix CORS before you blame the SDK

TL;DR The bug is usually the preflight ( OPTIONS ), not your fetch call or the client library. Access-Control-Allow-Origin: * and credentials: 'include' never work together. Echo an exact origin from an allowlist — not a wildcard — when the SPA and API sit on different hosts. Your SPA lives on https://app.example.com . Your API lives on https://api.example.com . You open DevTools, hit a button,…

CORS (Cross-Origin Resource Sharing) errors occur when a web application, running on one domain, tries to make requests to a different domain, and the server does not allow it. In this case, the issue lies with the server-side configuration, not the client-side SDK or fetch call. To resolve the problem, ensure that the API on https://api.example.com allows requests from the SPA running on https://app.example.com by specifying the correct Access-Control-Allow-Origin header in the response.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The Readonly Trap — PHP Value Objects & DDD Aggregates

readonly tells PHP a property can't be reassigned. It says nothing about whether two values are equal, or whether what's inside stays immutable.

  • Readonly keyword prevents property reassignment after construction in PHP
  • Value Objects remain immutable within file scope, not across broader system
  • Additional logic needed for equality and immutability enforcement in collections

More from Thursday 24 September →