Home
Support Forums

Can't access functions folder due to CORS error

I’m trying to access test netlify functions locally using netlify dev.
When I call a function, the function does not run, and I receive this error:

The Same Origin Policy disallows reading the remote resource at http://localhost:3000/.netlify/functions/testing

The server is running on localhost:8888

I’ve tried it with and without adding the following to netlify.toml

 [[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

[[headers]]
  for = "/"
    [headers.values]
      Access-Control-Allow-Origin = "*"

I’ve tried adding the Access-Control-Allow-Origin = "*" header to the response of the function.

It’s not that the response is blocked. The function doesn’t run.

I’ve tried turning it off and back on again.

Not sure what else to do. I have other projects that use netlify functions fine. But this specific project, despite having the exact same setup, just doesn’t work.

Has there been a breaking change to netlify dev? Have I made some rookie error? Any point in the right direction would be really appreciated. Thanks.

Hey @ShadowfaxRodeo,

Not my area of expertise but I do remember stumbling upon this thread once upon a time and I hope it steers you in the right direction!

Hope this helps someone Googling this question.

What fixed it for me was modifying my frontend code
from:
fetch('https://example.com/.netlify/functions/hello')
to:
fetch('/.netlify/functions/hello')

1 Like

Thanks for bringing this up, @vcamp!! We love knowledge sharing.