dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

When i run 'php artisan serve' all route 404 error #1556

Closed tranhuy605 closed 5 years ago

tranhuy605 commented 6 years ago

When i run "php artisan serve" and then config API_DOMAIN=http://127.0.0.1:8000 but all route use dingo can't access it throw 404 error

gazben commented 6 years ago

@tranhuy605 Did you set all the environment variables? Can you list the routes with php artisan api:routes?

Example dingo related .env variables:

API_STANDARDS_TREE=x
API_SUBTYPE=example
API_PREFIX=api
API_DOMAIN=
API_VERSION=v1
API_NAME="example API"
API_CONDITIONAL_REQUEST=true
API_STRICT=false
API_DEFAULT_FORMAT=json
API_DEBUG=true
JWT_SECRET=
Piquinikis commented 6 years ago

+1 Same problem here.

gazben commented 6 years ago

Laravel or Lumen? Can you post here your .env file?

Piquinikis commented 6 years ago

Yes, I'm sorry, this is my API configuration: API_NAME="USOE Backend" API_DEBUG=true API_DOMAIN=localhost:8002 API_VERSION=v1 API_DEFAULT_FORMAT=json API_STANDARDS_TREE=x API_SUBTYPE=example API_PREFIX=api API_CONDITIONAL_REQUEST=true API_STRICT=false

I'm running Laravel 5.6 in a Docker instance with Nginx 1.10 and PHP 7.2, on every API call I have a response "404 Not Found" with this trace:

"debug": { "line": 179, "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php", "class": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException", ...

specialtactics commented 6 years ago

Wouldn't you want your API_PREFIX to be null in this case? Otherwise it will want something like http://api.127.0.0.1:8000

Piquinikis commented 6 years ago

I'm sorry, yes my API_PREFIX option is empty right now and I did remove the port value from the API_DOMAIN and write only "localhost".

Not matters if my project is in port 8002, in my Dingo configuration I say it's localhost and this its works.

Maybe @tranhuy605 this is you need to solve your problem.

coilnovasince1985jenkins commented 5 years ago

@Piquinikis how did you manage to solve this? I've tried every possible solution found on the internet and in this git

Piquinikis commented 5 years ago

@coilnovasince1985jenkins I solved that problem setting an empty string as API_DOMAIN value. Right now, I have the project running in Laravel 5.8 with Dingo 2.0 and haven't any problem.

Good luck!

fredroo commented 3 years ago

@gazben please help me, list for me all env required in migration from 5.8 to 6, dingo 2.4.7