0

This issue is well documented but my attempts have been unsuccessful... any suggestions are welcome!

Recreating Error

cookiecutter gh:Buuntu/fastapi-react --no-input
cd fastapi-react-project

modified files before running build script (in order to address prior errors):

frontend/Dockerfile line 7

RUN npm install --legacy-peer-deps

docker-compose.yml line 37

  # flower:
  #   image: mher/flower
  #   command: celery flower --broker=redis://redis:6379/0 --port=5555
  #   ports:
  #       - 5555:5555
  #   depends_on:
  #     - "redis"
cd fastapi-react-project
chmod +x scripts/build.sh
./scripts/build.sh

Access to fetch at 'http://localhost:8000/api/v1' from origin 'http://0.0.0.0:8000' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local.

GET http://localhost:8000/api/v1 net::ERR_FAILED api.ts:4 <-- fetch()

Attempts

System

➜ uname -v
# Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64
➜ docker-compose version
# Docker Compose version v2.13.0

Additional Info

willwrighteng
  • 1,411
  • 11
  • 25

1 Answers1

1

Don't open http://0.0.0.0:8000/ in your browser; open http://localhost:8000/ instead. That way the origin matches.

AKX
  • 152,115
  • 15
  • 115
  • 172
  • wow, not sure how I missed that one! this may be a dumb question but why are these two different?... [nevermind](https://stackoverflow.com/questions/20778771/what-is-the-difference-between-0-0-0-0-127-0-0-1-and-localhost) – willwrighteng Jan 30 '23 at 11:12
  • 1
    I'm honestly surprised that the browser even does `0.0.0.0:8000`; I'd been under the impression zero was just an alias for listening. Live and learn! – AKX Jan 30 '23 at 11:18
  • 1
    @will-wright-eng It's not a dumb question, there are no dumb question. Don't let toxic people stop you from asking questions. Just saw this but AKX was faster, good luck! – saman93 Jan 30 '23 at 11:52