2023-10-15 19_54_20-awesometodos - Visual Studio Code.png

import { useEffect } from "react";

export default function App() {
  
  useEffect(() => {
    const getTodos = async () => {
      const res = await fetch("<http://localhost:5000/api/todos>");
      const todos = await res.json();

      console.log(todos);
    };

    getTodos();
  }, [])

  return (
    <main className="container">
      <h1>Awesome Todos</h1>
    </main>
  );
}

Access to fetch at 'http://localhost:5000/api/todos' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource…

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "<http://localhost:5000>",
  "dependencies": {
   //...
}
import { useEffect } from "react";

export default function App() {
  
  useEffect(() => {
    const getTodos = async () => {
      const res = await fetch("/api/todos");
      const todos = await res.json();

      console.log(todos);
    };

    getTodos();
  }, [])

  return (
    <main className="container">
      <h1>Awesome Todos</h1>
    </main>
  );
}

Untitled