question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite admin login loop with production build

See original GitHub issue

Bug report

Describe the bug

When running the Users starter project in production mode, you can’t reach the Admin UI. You keep getting prompted to login.

To Reproduce

  1. Create a new test project using yarn create keystone-app. Select the Users starter.
  2. Run the project in dev mode with the auth strategy temporarily removed so you can create an initial user.
  3. Log out and close the server.
  4. Restart the server in dev mode to verify your new User can log in and get to the admin UI.
  5. Log out and close the server.
  6. Run yarn build && yarn start.
  7. Try to access the Admin UI. You’ll get the login page as before. However, every time you log in you just end up back at the login screen. You can never reach the admin UI.

Expected Behavior

Should end up in the admin UI as in dev mode. Trying to navigate to localhost:3000/admin still sends you to the login page.

System information

  • OS: Windows 10 1903
  • Browser (if applies): Chrome 78

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
timlesliecommented, Oct 28, 2019

The problem here is related to secure cookies

A secure cookie is only sent to the server with an encrypted request over the HTTPS protocol.

By default, Keystone will use secure cookies in production, with the assumption that you will be running over HTTPS.

    secureCookies = process.env.NODE_ENV === 'production', // Default to true in production

The workaround if you don’t want to/can’t run HTTPS in production mode is to explicitly turn of secure cookies:

const keystone = new Keystone({
  name: PROJECT_NAME,
  adapter: new Adapter(),
  secureCookies: false,
});

@MadeByMike Could you work out where the best place is for this information to live in the documentation, because it’s definitely going to catch everyone when they first try to run in “production”.

0reactions
molombycommented, Mar 31, 2020

There’s some info related to this in my write up on Secure Cookies and Reverse Proxies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] Infinite redirect loop on login | Drupal.org
When any user (except admin) logs in, the site goes into a redirect loop. ... It's a production site and clients need to...
Read more >
laravel login infinite loop after deployment - php - Stack Overflow
domain.dev displays the admin dashboard if logged in, and the login page if not, while logging out returns the user to the login...
Read more >
Redirect loop when trying to login to /wp-admin/ [duplicate]
Stuck in an infinite loop when trying to log in to my wordpress site. I type in the URL/wp-admin and then it loops...
Read more >
OpenShift Web Console stuck in redirect loop
Logging into the admin cluster console throws an "Oh no! Something went wrong" error and redirects to the login page which then automatically ......
Read more >
Stuck in authorization login loop - Microsoft Q&A
/// <response code="400">If the redirect Url and state could not be built</response>; [HttpGet(Name = nameof( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found