Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api requests get 404 #321

Closed
dpolyakov opened this issue Apr 13, 2017 · 8 comments
Closed

Api requests get 404 #321

dpolyakov opened this issue Apr 13, 2017 · 8 comments
Labels

Comments

@dpolyakov
Copy link

dpolyakov commented Apr 13, 2017

No data in admin dashboard

Expected Behavior

See and manage links and users

Current Behavior

empty tables

Possible Solution

Steps to Reproduce (for bugs)

  1. install release Stable 2.1.1
  2. set config
SETTING_PUBLIC_INTERFACE=false
SETTING_INDEX_REDIRECT=https://github.com
  1. login
  2. create short link
  3. go to admin dashboard admin#links

Your Environment

@dpolyakov dpolyakov changed the title Api requests get 302 redirect Api requests get 404 Apr 13, 2017
@dpolyakov
Copy link
Author

dpolyakov commented Apr 13, 2017

I did changes in my config:

APP_DEBUG=true
SETTING_REDIRECT_404=false

Now, i am getting 404 status code for api GET requests

in Application.php line 1256
at Application->handleDispatcherResponse(array('0')) in Application.php line 1212
at Application->Laravel\Lumen\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 20
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1439
at Application->sendThroughPipeline(array('Illuminate\Cookie\Middleware\EncryptCookies', 'Illuminate\Session\Middleware\StartSession', 'Illuminate\View\Middleware\ShareErrorsFromSession', 'App\Http\Middleware\VerifyCsrfToken'), object(Closure)) in Application.php line 1213
at Application->dispatch(null) in Application.php line 1153
at Application->run() in index.php line 28

POST working correctly

@cydrobolt
Copy link
Owner

Sorry, I'm not sure I understand where the error is occurring. You said this is related to the API, but in your steps, you said to navigate to /admin#links.

Could you provide a URL path that could be used to reproduce the issue?

@dpolyakov
Copy link
Author

I`m opening dashboad and getting error:

DataTables warning: table id=user_links_table - Ajax error. For more information about this error, please see http://datatables.net/tn/7

Then Im opening chrome devtools, opening to tab Networkand found that requests to/api/v2/admin/get_admin_usersand/api/v2/admin/get_user_links` faled with 404 code

image

P.S. sorry for my bad english

@cydrobolt
Copy link
Owner

cydrobolt commented Apr 13, 2017

I did some digging, and it seems like the endpoint is present in your app. The controller involved, AdminPaginationController, isn't designed to return any 404s. However, it's possible that laravel-datatables is returning 404s.

It seems like this might be due to a database issue. Is your database properly running? Are you able to log out and log back in?

Could you execute USE <polr_DB>; DESCRIBE links; in a SQL shell? Did you run the setup script or migrate the database manually using artisan? It looks like you could have missing tables.

@dpolyakov
Copy link
Author

mysql>  DESCRIBE links;
+---------------+------------------+------+-----+---------------------+----------------+
| Field         | Type             | Null | Key | Default             | Extra          |
+---------------+------------------+------+-----+---------------------+----------------+
| id            | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
| short_url     | varchar(255)     | NO   | UNI | NULL                |                |
| long_url      | longtext         | NO   |     | NULL                |                |
| ip            | varchar(255)     | NO   |     | NULL                |                |
| creator       | varchar(255)     | NO   |     | NULL                |                |
| clicks        | int(11)          | NO   |     | 0                   |                |
| secret_key    | varchar(255)     | NO   |     | NULL                |                |
| is_disabled   | tinyint(1)       | NO   |     | 0                   |                |
| is_custom     | tinyint(1)       | NO   |     | 0                   |                |
| is_api        | tinyint(1)       | NO   |     | 0                   |                |
| created_at    | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
| updated_at    | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
| long_url_hash | varchar(10)      | YES  | MUL | NULL                |                |
+---------------+------------------+------+-----+---------------------+----------------+
13 rows in set (0.01 sec)

it`s new installation

@cydrobolt
Copy link
Owner

Perhaps this is an environment issue? yajra/laravel-datatables#717
I'm unable to reproduce this issue with the latest ref (d8dd8d6)

Could you try running php artisan migrate:refresh and see if that helps? If you run SELECT * FROM links, are the URLs being inserted into the database at all?

@cydrobolt
Copy link
Owner

cydrobolt commented Apr 13, 2017

It's possible that the GET requests are being truncated (i.e, your server won't allow such a large URL).
https://demo.polr.me is also running nginx and php-fpm, and it seems to be running without problems.

It might have to do with the max_input_vars setting in your PHP installation.

@dpolyakov
Copy link
Author

It was my mistake in nginx configuration:

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

instead of

    location / {
        try_files $uri $uri/ /index.php$is_args$args
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants