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

404 on Github login on Cloudflare #987

Open
NoelOConnell opened this issue Mar 7, 2024 · 4 comments
Open

404 on Github login on Cloudflare #987

NoelOConnell opened this issue Mar 7, 2024 · 4 comments

Comments

@NoelOConnell
Copy link

The /keystatic page renders the "login with Github" button but clicking that gives a 404.

From the logs in Cloudflare

 "logs": [
    {
      "message": [
        "10:14:19 [WARN] [router] No API Route handler exists for the method \"GET\" for the route \"/api/keystatic/github/login\".\nFound handlers: \"ALL\", \"prerender\"\n"
      ],
      "level": "log",
      "timestamp": 1709806459296
    }
  ],

It seems that the handler is null https://github.com/withastro/astro/blob/e88eeb033749bd6bce8c00e712e207690ae9bf79/packages/astro/src/runtime/server/endpoint.ts#L26

It's a empty site with just a single index.astro page.
This is what gets built and uploaded to Cloudflare.
image

Here's the dependency list

"dependencies": {
    "@astrojs/cloudflare": "^9.0.2",
    "@astrojs/markdoc": "^0.9.0",
    "@astrojs/react": "^3.0.10",    
    "@keystatic/astro": "^5.0.0",
    "@keystatic/core": "^0.5.0",
    "@tailwindcss/forms": "^0.3.3",
    "@tailwindcss/typography": "^0.4.1",
    "@types/react": "^18.2.55",
    "@types/react-dom": "^18.2.19",
    "astro": "^4.4.10"
    ....
    }

I also forked Emma's Keystatic Cloudfare demo repo and updated packages and it shows the same issue.

@emmatown
Copy link
Member

emmatown commented Mar 7, 2024

I just upgraded https://github.com/emmatown/keystatic-astro-cloudflare-workers-test and it seems to be working fine?

@NoelOConnell
Copy link
Author

Thanks for the reply, I updated my fork to match your recent changes and still have the same issue.

https://keystatic-astro-cloudflare-workers-test-env.pages.dev/
https://github.com/NoelOConnell/keystatic-astro-cloudflare-workers-test

It deploys fine and the site works but I can't get pass the "login with Github" button on the /keystatic page so I can't go through the Github setup flow as per the docs.
https://keystatic.com/docs/github-mode#connecting-with-git-hub

Is there any specific Cloudflare options/configuration required?
Is there a way to setup the Github app another way to see if that is the part causing the issue?

@NoelOConnell
Copy link
Author

NoelOConnell commented Mar 12, 2024

Okay, I manage to get it to work.

I ran the project locally in github mode and I was able to go through the "login with Github" flow to create the Github app.
Since it was setup locally is saves the localhost url for the callback links so I had to manually edit the newly create app in my Github account using the link https://github.com/settings/apps/{app name here} in my case that was {githubusername-keystatic}. I also had to add the new created KEYSTATIC_ variables to Cloudflare.

They /keystatic url now works and loads correctly but I can't make any changes, I just get [GraphQL] Resource not accessible by integration for any action. Update, I had to install the app on the repo since that part of the workflow failed due to the incorrect callback path for localhost.

So the issue is setting up the Github workflow and not the Cloudflare adapter.

@jossmac
Copy link
Member

jossmac commented Apr 12, 2024

@NoelOConnell can this issue be closed?

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

No branches or pull requests

3 participants