# Blocked by CORS policy:

**URL:** <https://forum.infinityfree.com/t/blocked-by-cors-policy/55712>\
**Category:** Hosting Support\
**Created:** [December 13, 2021, 10:11am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712 "2021-12-13T10:11:09Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 13, 2021, 10:11am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/1 "2021-12-13T10:11:09Z")

</div>

![infinityBulok](https://forum-cdn.infinityfree.net/original/3X/3/7/3749d1184fe995b65f5f1f02c1920edfd44acf9f.png)  
i’m having an error in my compiler.php when I host It in here in infinity free. how can i fix this?

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 13, 2021, 10:49am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/2 "2021-12-13T10:49:22Z")

</div>

I’m confused. You shared a picture of some Java code, not any PHP. What is the actual error you see from the _PHP_ code? To get a useful error, please enable PHP Display Errors:

> [@Http error 500](https://forum.infinityfree.com/t/http-error-500/49352#getting-the-real-error-message-2):
>
> When trying to access your website, you may see a page which returns the status code “500”. In Google Chrome, you’ll see a page with the error code HTTP ERROR 500. There are typically two reasons which can cause this error: The PHP code has crashed. The .htaccess file contains invalid rules. Here are some things you can try to debug and fix this. Fixing crashing PHP code A HTTP ERROR 500 simply tells you that the PHP code has crashed, but gives no information as to why it has crashed. Gett…

Edit: The error that is showing in the console is a “file not found” error. Please ensure the file exists.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 13, 2021, 10:51am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/3 "2021-12-13T10:51:43Z")

</div>

Im trying to create a simple java compiler. It works when it is in a localhost but when i host it here in infinity free or other web hosting services, i get this error which is blocked by cors policy, i’m literrally new to this, i don’t know how to fix this

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 13, 2021, 10:53am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/4 "2021-12-13T10:53:27Z")

</div>

Can you share the part of your php code that is failing? Be sure to wrap it in three tildes (~~~)!

Edit: If it doesn’t work on other hosts either, it is most likely your code crashing.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 13, 2021, 11:01am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/6 "2021-12-13T11:01:47Z")

</div>

![compiler](https://forum-cdn.infinityfree.net/original/3X/4/e/4e03dc8e6335048b737f0e62234dbd3dfe0beea0.png)

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 13, 2021, 11:05am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/7 "2021-12-13T11:05:09Z")

</div>

Your problem is on lines 19 and 13. You can’t run `shell_exec` here or on any other free host for security reasons.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 13, 2021, 11:11am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/8 "2021-12-13T11:11:16Z")

</div>

how can i solve this? man i really need this java compiler in order to graduate haha

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [December 13, 2021, 11:15am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/9 "2021-12-13T11:15:35Z")

</div>

Buy a dedicated server and install Java. Also, all of these servers are Linux, but you can get Windows with a dedicated server (I think). Or you can just host it on your localhost.

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [December 13, 2021, 3:55pm UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/10 "2021-12-13T15:55:48Z")

</div>

I STRONGLY recommend to run this on your local system, or at least something isolated, and to never let anyone else use this. You’re allowing anyone to submit code to run on the server. That’s called “Remote Code Execution”, which is a VERY severe kind of security vulnerability. You’re opening all doors and windows to get brutally hacked here.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 14, 2021, 4:41am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/11 "2021-12-14T04:41:43Z")

</div>

so there’s now way i can deploy it to the internet without this kind of error?

---

<div class="post-metadata">

**Author:** ![jaikrishna.t](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/jaikrishna.t/32/57109_2.png) [@jaikrishna.t](https://forum.infinityfree.com/u/jaikrishna.t)\
**Post date:** [December 14, 2021, 4:52am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/12 "2021-12-14T04:52:01Z")

</div>

Nope, you need to host it on your own VPS or some shared hosting (all paid)! If you’re doing this for dev purposes, use xampp, wamp etc.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 14, 2021, 4:58am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/13 "2021-12-14T04:58:25Z")

</div>

Okay, thanks. One last question how can i upload 300mb file here in infinity free? Is there a limit for the size of uploading file here?

---

<div class="post-metadata">

**Author:** ![jaikrishna.t](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/jaikrishna.t/32/57109_2.png) [@jaikrishna.t](https://forum.infinityfree.com/u/jaikrishna.t)\
**Post date:** [December 14, 2021, 4:59am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/14 "2021-12-14T04:59:33Z")

</div>

Yeah, there is a 10 MB file size limit.

---

<div class="post-metadata">

**Author:** ![anon17424056](https://forum.infinityfree.com/letter_avatar/anon17424056/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon17424056](https://forum.infinityfree.com/u/anon17424056)\
**Post date:** [December 14, 2021, 5:00am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/15 "2021-12-14T05:00:52Z")

</div>

so there’s no way i can upload 300mb file here?

---

<div class="post-metadata">

**Author:** ![jaikrishna.t](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/jaikrishna.t/32/57109_2.png) [@jaikrishna.t](https://forum.infinityfree.com/u/jaikrishna.t)\
**Post date:** [December 14, 2021, 5:02am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/16 "2021-12-14T05:02:02Z")

</div>

Yes, you can’t, sad 😵.

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [December 14, 2021, 10:10am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/17 "2021-12-14T10:10:38Z")

</div>

You could sandbox the code. Run the code with a security confinement around it so it can’t affect other parts of the system. This is pretty much what we do too to make sure your site can’t affect the sites of other people.

But sandboxing is hard. And given that your current code is just “write it to disk and run it”, getting that right seems to be too much to ask. So if all you want is to build an online compiler for a school project, that’s too much to ask.

And if there are other people who want to test code but don’t have anywhere to run it themselves, I would suggest referring them to a hosting provider that offers online compilation, instead of trying to build it yourself first.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [December 21, 2021, 10:11am UTC](https://forum.infinityfree.com/t/blocked-by-cors-policy/55712/18 "2021-12-21T10:11:18Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
