lemberg / connfa-integration-server

Connfa CMS & Integration Server
Apache License 2.0
31 stars 43 forks source link

Not able to access API with custom domains #8

Open jayram88 opened 7 years ago

jayram88 commented 7 years ago

Tried hosting the server on my server, while the normal get calls work ("app" ones) I get 404 errors for all the API calls. Sample call: www.mycustomconnfa.com/login or /dashboard works.

But www.mycustomconnfa.com/api/v2/checkUpdates throws a 404 error. you can replace mycustom.com with localhost:8000 and get the same results.

But using your default base url works (http://connfa-integration.uat.link/)

Any pointers?

yuriymyrosh commented 7 years ago

Hi @jayram88,

It could be wrong configuration for API in your .env file. We use next configurations:

API_PREFIX=api
API_DOMAIN=
API_VERSION=v2
API_DEBUG=true
API_CONDITIONAL_REQUEST=false

Note that API_DOMAIN is empty, please try to make the same in your .env

jayram88 commented 7 years ago

Thanks for the quick reply @Konro1 , Making API_DOMAIN empty does not solve the issue unfortunately.

What I have figured so far is that the issue is in the match() function in RouteCollection.php. $route = $this->check($routes, $request);

Here the check is returning null for all "api" calls but returning fine for the other "app" calls. Any other ideas?

jayram88 commented 7 years ago

Does this have something to do with URL rewriting? I am using Homestead locally.

yuriymyrosh commented 7 years ago

@jayram88 you can use php artisan api:routes command to see all API routes paths (e.g.: /api/v2/checkUpdates). Full url will look like: http://YOUR_DOMAIN/api/v2/checkUpdates. Please, note that your domain DOOCUMENT_ROOT need to be configured to public directory and all routes in laravel are case sensitive.

jayram88 commented 7 years ago

Sorry, document root is configured to public and the URL is as you recommended too, there is some difference between how API URIs are matched vs APP URIs....not able to figure it :/

yuriymyrosh commented 7 years ago

Could you check if your web server has mod_rewrite enabled?

jayram88 commented 7 years ago

Yes, I am using Fortrabbit and its supposed to be enabled there by default. I suspected the same too though. Do you recommend any particular hosting service that I could try it on to confirm this? (Or any other ideas?)

jayram88 commented 7 years ago

@Konro1 mod_rewrite is enabled on my server, confirmed it with another htaccess script. Any other ideas?

matchett808 commented 7 years ago

Does it work if you run the app from Chrome on your machine?

If not - can you use inspector to get the full URL it's requesting?

If you're running it on a mobile device, it may be a DNS issue - I've been playing with connfa recently and ran into some network issues so hope this might help clarify...

jayram88 commented 7 years ago

@matchett808 I am making the calls manually on chrome and seeing the difference in response between the default base URL and the url of my server(and localhost). Have you managed to host it successfully on your own? What server(service) did you use? And how did you get around your DNS issue?

piraterr commented 7 years ago

Hi @Konro1

I think I have the same issue, please see here: http://164.132.197.232/connfa/public/api/v2/checkType

Any idea how to fix this?

yuriymyrosh commented 7 years ago

Hi, @piraterr

There is no api url http://164.132.197.232/connfa/public/api/v2/checkType, there is http://164.132.197.232/connfa/public/api/v2/checkUpdates, it works.

You can read about all API endpoints here http://connfa.com/api/

piraterr commented 7 years ago

Thank you @Konro1 for prompt reply and for the hint.

yuriymyrosh commented 7 years ago

@jayram88 Just want to follow up on this, is the problem still relevant, or could the issue be closed? If there are any questions, just let me know.

phls commented 7 years ago

Hi, just to know, I had to use (with index.php):

http://MY-DOMAIN/index.php/api/v2

yuriymyrosh commented 7 years ago

@phls It seems like you have not mod_rewrite enabled on your web server

phls commented 7 years ago

@Konro1 mod_rewrite is enabled, but still working with index.php

yuriymyrosh commented 7 years ago

@phls Do you have .htaccess file in public/ directory ?

phls commented 7 years ago

@Konro1 yes.