Slim framework POST doesn't work in subdomain


#1

I have a strange problem. Everything works when I have my slim framework on www.domain.com/api and my app on www.domain.com/app

When I move my app to app.domain.com it doesn’t work anymore. All the GET requests stil work, but my POST doesn’t. I already enabled CORS in the .htaccess and otherwise my GET shouldn’t work i guess. Any ideas?


#2

We might need more details about what you mean by “doesn’t work”. Are you getting an error? What do the server logs say for the request? What is in the response you get back? 404? 500? 200? Is there any configuration per environment you might have missed? We don’t necessarily need the answers to all of those… but we probably need to know a little more to be able to help steer you in the right direction.


#3

Yes, I forgot to mention any details. I get a “Failed to load resource: net::ERR_EMPTY_RESPONSE”.

Don’t know about any missed configuration, it all worked fine till I changed my app url to a subdomain instead of subfolder on the main domain.


#4

You have a CORS issue. You should read our documentation on how to fix it.
https://www.slimframework.com/docs/cookbook/enable-cors.html


#5

It was indeed a CORS issue, and I was able to solve it. Thanks.