Blocked by CORS policy:

i’m having an error in my compiler.php when I host It in here in infinity free. how can i fix this?

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:

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

1 Like

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

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.

1 Like

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


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

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.


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.


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

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.


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?

1 Like

Yeah, there is a 10 MB file size limit.


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

Yes, you can’t, sad :dizzy_face:.

1 Like

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.


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