0

I am using netlify for frontend and fastapi in the backend which is hosted in deta space. My front end is running from "https://actuallyinflint.netlify.app" but I have custom dns for "https://actuallyinflint.com"

However I keep getting the cors error but I added the origin in my backend

This is my backend origins

from starlette.middleware.cors import CORSMiddleware

origins = [
    "http://localhost",
    "http://localhost:3000",
    "https://actuallyinflint.netlify.app/",
    "https://actuallyinflint.netlify.app",
    "https://actuallyinflint.com"
    "https://actuallyinflint.com/"
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["GET", "POST", "OPTIONS"],
    allow_headers=["*"],
)

This is the error I get in my browser

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https:myDetaSpaceHostedUrl. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 500.

The header

POST /upload/4th%20of%20July%2F HTTP/1.1
Host: myDetaSpaceHostedUrl
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://actuallyinflint.netlify.app/
Content-Type: multipart/form-data; boundary=---------------------------396167196518845472703356094571
Content-Length: 5213567
Origin: https://actuallyinflint.netlify.app
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Amolgorithm
  • 697
  • 2
  • 20
thatonenerd
  • 134
  • 2
  • 13
  • When an exception occurs - i.e. when you end up with a status code of 500 - no CORS headers are added to the error response. This is not a CORS issue - the CORS issue is just one of the symptoms of another problem, effectively meaning that your backend service isn't working as it should for the request you're making. (See `Status code: 500.` in the error message) – MatsLindh Jul 07 '23 at 08:15
  • For information, neither `https://actuallyinflint.netlify.app/` nor `https://actuallyinflint.com/` are valid Web origins. Web origins do not contain a path. See https://stackoverflow.com/questions/70353729/access-from-origin-https-example-com-has-been-blocked-even-though-ive-allow – jub0bs Jul 07 '23 at 10:45

0 Answers0