<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Emily Scott</title>
    <description>The latest articles on DEV Community by Emily Scott (@idioms).</description>
    <link>https://dev.to/idioms</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3782168%2Fc2524324-8382-4140-9dd7-da4d4234ef2f.png</url>
      <title>DEV Community: Emily Scott</title>
      <link>https://dev.to/idioms</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/idioms"/>
    <language>en</language>
    <item>
      <title>How to Fix “Blocked by CORS Policy” Error in JavaScript (Step-by-Step Guide)</title>
      <dc:creator>Emily Scott</dc:creator>
      <pubDate>Sat, 21 Feb 2026 04:34:20 +0000</pubDate>
      <link>https://dev.to/idioms/how-to-fix-blocked-by-cors-policy-error-in-javascript-step-by-step-guide-48h6</link>
      <guid>https://dev.to/idioms/how-to-fix-blocked-by-cors-policy-error-in-javascript-step-by-step-guide-48h6</guid>
      <description>&lt;p&gt;How to Fix “Blocked by CORS Policy” Error in JavaScript (Step-by-Step Guide)&lt;/p&gt;

&lt;p&gt;If you are building a web application and see this error in your browser&lt;br&gt;
console:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access to fetch at 'https://api.example.com' from origin 'http://localhost:3000' 
has been blocked by CORS policy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is one of the most common issues beginners face when working with&lt;br&gt;
JavaScript and APIs.&lt;/p&gt;

&lt;p&gt;In this article, you will learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  What CORS is&lt;/li&gt;
&lt;li&gt;  Why this error happens&lt;/li&gt;
&lt;li&gt;  How to fix it in Node.js (Express)&lt;/li&gt;
&lt;li&gt;  How to fix it in PHP&lt;/li&gt;
&lt;li&gt;  Best practices for production&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;What Is CORS?&lt;/p&gt;

&lt;p&gt;CORS (Cross-Origin Resource Sharing) is a browser security feature.&lt;/p&gt;

&lt;p&gt;A request is considered cross-origin when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Your frontend runs on &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  Your backend runs on &lt;a href="https://api.example.com" rel="noopener noreferrer"&gt;https://api.example.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because these origins are different, the browser blocks the request&lt;br&gt;
unless the server explicitly allows it.&lt;/p&gt;

&lt;p&gt;Important: CORS is enforced by the browser, not by the server.&lt;/p&gt;




&lt;p&gt;Why the CORS Error Happens&lt;/p&gt;

&lt;p&gt;CORS errors occur because the backend server does not send the correct&lt;br&gt;
HTTP headers.&lt;/p&gt;

&lt;p&gt;The browser checks for headers like:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access-Control-Allow-Origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If the header is missing, the browser blocks the request.&lt;/p&gt;

&lt;p&gt;This means you cannot fix CORS from the frontend alone.&lt;br&gt;
It must be configured on the backend.&lt;/p&gt;




&lt;p&gt;Solution 1: Fix CORS in Node.js (Express)&lt;/p&gt;

&lt;p&gt;First, install the CORS middleware:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then update your Express server:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const cors = require('cors');

const app = express();

app.use(cors());

app.get('/api/data', (req, res) =&amp;gt; {
  res.json({ message: "CORS is fixed!" });
});

app.listen(5000, () =&amp;gt; console.log("Server running on port 5000"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Restart the server and test your request again.&lt;/p&gt;




&lt;p&gt;Solution 2: Fix CORS in PHP&lt;/p&gt;

&lt;p&gt;If you are using PHP, add the following headers at the top of your PHP&lt;br&gt;
file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This allows cross-origin requests.&lt;/p&gt;




&lt;p&gt;Important: Do Not Use “*” in Production&lt;/p&gt;

&lt;p&gt;Using:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header("Access-Control-Allow-Origin: *");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Allows requests from any domain.&lt;/p&gt;

&lt;p&gt;In production, it is safer to specify your domain:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header("Access-Control-Allow-Origin: https://yourdomain.com");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;Why Postman Works But the Browser Fails&lt;/p&gt;

&lt;p&gt;You may notice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Postman works&lt;/li&gt;
&lt;li&gt;  Browser fails&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This happens because CORS is enforced only by browsers.&lt;br&gt;
Postman does not enforce CORS restrictions.&lt;/p&gt;




&lt;p&gt;Quick Debug Checklist&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Confirm CORS headers are set on the backend&lt;/li&gt;
&lt;li&gt;  Restart the server&lt;/li&gt;
&lt;li&gt;  Clear browser cache&lt;/li&gt;
&lt;li&gt;  Check the browser console again&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;The “Blocked by CORS Policy” error is not a JavaScript bug.&lt;br&gt;
It is a browser security rule.&lt;/p&gt;

&lt;p&gt;Once you understand that CORS must be configured on the backend, the&lt;br&gt;
solution becomes straightforward.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>php</category>
      <category>node</category>
    </item>
    <item>
      <title>My Journey into Web Development (And Why I Started with JavaScript)</title>
      <dc:creator>Emily Scott</dc:creator>
      <pubDate>Fri, 20 Feb 2026 07:36:04 +0000</pubDate>
      <link>https://dev.to/idioms/my-journey-into-web-development-and-why-i-started-with-javascript-2p8f</link>
      <guid>https://dev.to/idioms/my-journey-into-web-development-and-why-i-started-with-javascript-2p8f</guid>
      <description>&lt;p&gt;Hi everyone, 👋&lt;/p&gt;

&lt;p&gt;I’m a beginner web developer currently learning JavaScript, HTML, CSS, and PHP, and recently exploring AI integration in web apps. I wanted my first post to share why I started — and what I’ve learned so far.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I Started Learning Web Development&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’ve always been curious about how websites actually work. Not just how they look, but how they function behind the scenes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When I discovered that:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML structures the content&lt;/li&gt;
&lt;li&gt;CSS styles the design&lt;/li&gt;
&lt;li&gt;JavaScript makes it interactive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...it suddenly felt less mysterious and more achievable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 My Current Learning Focus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Right now, I’m focusing on:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅ Writing clean HTML structure&lt;/p&gt;

&lt;p&gt;✅ Building responsive layouts with CSS&lt;/p&gt;

&lt;p&gt;✅ Understanding JavaScript fundamentals (variables, functions, loops)&lt;/p&gt;

&lt;p&gt;✅ Exploring how AI APIs can connect with web apps&lt;/p&gt;

&lt;p&gt;I’m not trying to rush into advanced frameworks yet. I want strong fundamentals first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔍 Biggest Lesson So Far&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consistency beats intensity.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It’s easy to feel overwhelmed when you see experienced developers building complex apps. But I’ve learned that small daily progress — even 30–60 minutes — adds up quickly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎯 What’s Next?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn DOM manipulation deeply&lt;/li&gt;
&lt;li&gt;Build small interactive projects&lt;/li&gt;
&lt;li&gt;Experiment with simple AI-powered features&lt;/li&gt;
&lt;li&gt;Improve my Git &amp;amp; GitHub workflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're also a beginner, I’d love to connect.&lt;br&gt;
What are you currently learning?&lt;/p&gt;

&lt;p&gt;Let’s grow step by step. 🚀&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
