How To Fix: "null has been blocked by CORS policy" Error in JavaScript AJAX
In today's video I'll be showing you how to fix the common CORS policy error which reads: ... from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported etc.
The problem is that you are most likely serving your HTML directly from your system, whereas instead you should be using a web server to serve your HTML, CSS, JavaScript or images.
A similar video on CORS:
• Access-Control-Allow-O...
Join this channel to get access to perks:
/ @dcode-software
For your reference, check this out:
developer.mozilla.org/en-US/d...
💜 Join my Discord Server:
/ discord
🎨 Download my Visual Studio Code theme:
marketplace.visualstudio.com/...
Support me on Patreon:
/ dcode
Follow me on Twitter:
@dcodeyt
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
#dcode #javascript
Пікірлер: 180
I hate when they say "a very simple fix" lol
When running that live server option in Visual Studio Code what's the keyboard shortcut for macOS to open up that panel? (he uses F1 on windows)
Excellent and thank you for saving me another two hours of checking my code!
Perfectly summed up.... Easy and great fix. Thanks bruv
Pretty awesome! I think every programmer had faced this problem before. Even I faced it as well and fixed it by using live server extension. Thanks so much bro for helping people to solve this issue.
@chembetikarunakar814
Жыл бұрын
Without liveserver can we do this
Do I have to re-save my file in VS code? When I hit enter after doing the f1 I get a message on the bottom of vs that says open workspace.
Excellent explanation. Simple and short.. Easy to understand. Thnx man 👍🏻
You man are a live safer. I've been banging my head for the past 3 hours and I feel relieved to have finally solved my problem. Thank you very much sir!
woah! what a coincidence! I was just searchin' to fix this problem and got your video just uploaded
Thank you so much! That was really helpful!
This video is the response to my 2 weeks problem. Thank you sooo much!
@Olalekan.Ekundayo
Жыл бұрын
So, I found someone like me that was stuck with this error message for weeks 😂
Thanx for posting this Bro. It was a great help!
Thanks so much! You saved me a lot of time and frustration!
This really helps me a lot! Truly appreciate!!!
thanks man, helped with starting my journey learning react, I was getting pretty frustrated as I wasnt even able to print hello world but now i should be able to actually get going, thanks!
Thank you. This was extremely helpful Kudos to you.
Thanks a lot! Great Explanation.
Thank you bro, your explanation saved me loads of time! Thanks!!
Pretty awesome!! Great Explanation. Well Thanks a lot.
ok so file on hard drive with extension html or htm or any other cannot access pages from (say) a news or literature site but what if i am writing an android app using cordova platform ... once i finish writing app following your work arounds and i upload app will it work on any android which has "bought" from app store? ... remember person who "buys" just gets app ... will ajax or fetch still work because no server is running on android device of buyer afaik ... my code is not for a client's website but for a device like android ... when it is game like wordle hosted on nytimes website's games page it is still an access from server to server but when an app is running on an android device it is running exactly like a file from storage just like your error giving file ... please correct me if i am wrong
Wow! You just gave me a solution to the error message I have been encountering for weeks now, and has slow down my learning... Thank you very much, you deserved a like and a subscribe from me 😄
@my.b707
11 ай бұрын
The same, that slow my learning an I was sad. Now I can continue
I'm over here training neural networks and getting ready to pull my hair out because CORS wouldn't let me load my trained models (ML5.js library). I let out a huge sigh of relief when you said VS Code has a server extension, I was worried I was going to have to design a Node.js overlay. Every things working, thank you so much.
Thanks man for the explanation. This helped me to solve the problem 🙂👍
Thank you a lot. It worked!
Is there any way to do it without live server extention?
Thank you so much It really helped me
This video fixed my javascript csv loading problem too. Thank you very much.
but then whuy do you get the error if you fetch it from your own harddrive?
How do you fix it if downloading a webserver is not an option?
Thankyou! It's helping😁
Is live server like local host ?or they're different stuff ?
I'm having the same error but i'm using fetch(). I tried to load the page with live server but still doesn't work. Any advise?
maaaaaaaaaaaaan your the best !!! I need your tutorial for the timer and i was getting this error you fixed it for me!1 great job ! you and coding train:))) are my favorite developers ever.
Awesome as always 👍😀
Thank you so much. :) It worked for me
Very helpful thanks!
Thank you, very helpful
You helped us a lot, dude
Thanks for the great video!
Thank youu so much.. your video is so helping 😭
thanks so much really apreciated
Thank You man! You are a life saver!
Thank God! Randomly I found your video. Thank u 😊
Did you do the voice for the whale in the beached whale / chips bru video?
Fantastic video! I hope this will solve my problem. Will try to upload my files to my server and see if the problem still occurs.
Great! Was super helpful
Thanks, it's helpful for me.
Hi, thank you for the video, my problem is a bit diferent, my cliente need the site to run offline in a company, and he can´t install the server in machines, because security compliance, how can i fix that? i´ve been trying this for more then 24 hours. I´ve created a bat file to open navigators without security in anonimous mode, however that´s not the ideal
thank u buddy, its very simple
te lo agradezco mucho estaba pariendo y pujando por ese error, pero gracias a ti lo he corregido. Awesome, thanks
Thank you so much...amazing video
thanks man it's really working
Oh man, thank you so much, you save my life.
appriciated man .. thanks😇
problem is this only works for the .html alone. no other .js or .css file in the folder, which ofc breaks the project
Thank you dCode. You just solved it issue
thanks for the help !
Saved me what would have been hours of scouring the internet. Thank you so much
If I dont want to use a web server?
Thanks for your help.
Thanks man, excellent explanation.
Modules in vanilla JavaScript produce the same error, BTW :-) and you totally rawk, because this worked on that too. Thank you.
Thanks so much!!!!! 🙏
yo, thank you so much! :D
Thank You Sir this video is very help full for me Thank altos!
Thanks this helped me a lot
Sir i am still getting error. while trying to add form data to google sheet
Thank you soo much!
thanks so much for this! you saved my bacon!
Thank you very much!
Oh my lord, thank you! As a rookie this was being a truly headache.
If you were standing in front of me, I would have kiss you buddy, spent like 2 days trying to fix this issue, and posted comments on stack flow for help you explained it well, easy to follow and for someone who is Dyslexic your tutorial was disable people-friendly too. well done.
I'm used to active live server, but this time I didn't cause I thought there will be some problem with scss ( it is the first time with this preprocessor) And I was searching different solutions. I did not expect it at all jajaj my gosh, thanks indeed!!
You are the best. You save my time a lot. Many thanks!!
Thank you!
life saver thank you
thank u ser, it works
It's working for me.thanks
Ty, you saved my life.
works for me, thanks ; )
Super Helpful
Thanks a lot!!!!
thx, u rly helps me
@dcode-software
Жыл бұрын
YOu're very welcome
Excellent!
Helpful!!!
Very good!
Can you show how to solve this issue with the fetch method ?
really simple and helpful, thanks so much
Is this only for the websites I own or can I edit other websites using this method?Because I am facing some problem in sending pictures through instagram dm in instagram web I don't know why it's happening but it's a major issue for me and when I opened developer options it said that it was blocked by CORS policy,so I just wanted to know if there is any way to fix it and I literally have no idea about it so if you can make a video on it, then it would be really helpful.Please help🙏🙏
thanks brother you are the best
thanks man!
thx alot dude the extension shit is the simplest
Thank man you saved me
I am already using live server in vs code but still getting this error. Can anyone help??
@aviuvaydov5690
Жыл бұрын
were you able to figure it out? I'm getting the same error
Thanks man
What about in GeoServer
thank you ❤️
thx a lot a was with this error for 1 week
Thank you
thanks mate :D