The change needs to be done in the space exploration mod. It has a lua script that sets the so called collission masks for all entity types and decides which ones get blocked from space. To fix this you need to open the mod archive of space exploration, go to prototypes/phase 3/space-collissions.lua and add this line
and (not string.find( prototype.name, "factory-", 1, true))
after that line
and (not string.find( prototype.name, "valve", 1, true)).
should be around line 328.
One problem though, you still cant put the space only entities inside the factories, because those have a different tile. If you enabled that, you could do all the space science stuff from the planets surface. The optimal solution would be to add space only factory buildings so you dont break the space exploration mod