DEV Community

If Everything Is Running on Localhost, Why Do We Still Get CORS Errors? (opens in new tab)

Discussed on DEV

One question almost every frontend developer asks at some point: "My frontend is running on localhost:3000 and my backend is running on localhost:5000. Both are on my own machine. Why am I still getting a CORS error?" It feels strange because both applications are literally running on the same laptop. The answer lies in how browsers define an Origin. What Is an Origin? An origin is made up of: Protocol + Domain + Port For example: and have: Same protocol ✅ Same domain ✅ Different ports ❌ Beca...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help