{"id":15774833,"url":"https://github.com/katt/test","last_synced_at":"2025-03-31T14:34:55.416Z","repository":{"id":140088171,"uuid":"248294851","full_name":"KATT/test","owner":"KATT","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-18T17:12:50.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-04T16:41:25.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KATT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-18T17:12:47.000Z","updated_at":"2020-03-18T17:12:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"9321ee07-e87c-4b2b-8231-1558f9479f0e","html_url":"https://github.com/KATT/test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"vgrafe/nextjs-auth0-hasura","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Ftest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Ftest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Ftest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Ftest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KATT","download_url":"https://codeload.github.com/KATT/test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246483574,"owners_count":20784913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T16:40:52.550Z","updated_at":"2025-03-31T14:34:55.382Z","avatar_url":"https://github.com/KATT.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NextJS - Auth0 - Hasura\n\nThis repo sits on the shoulders of the following giants:\n\n- https://github.com/auth0/nextjs-auth0\n- https://github.com/sandrinodimattia/nextjs-auth0-example\n- https://github.com/zeit/next.js/tree/canary/examples/auth0\n\n## Features\n\n- ⚡️ compatible with Next.js 9's Automatic Static Optimization\n- 🚫 no custom server code\n\n## Demo\n\nTry it [here](https://nextjs-auth0-hasura.vgrafe.now.sh/)\n\nPlease note: the heroku instance might be inactive when you try logging in, resulting in a failed attempt. Try again and it will work. Damn cold starts!\n\nOne way I found to avoid this is to make a dummy http call to the heroku instance in an `_app.js` file:\n\n```js\nimport App from 'next/app';\nimport fetch from 'isomorphic-unfetch';\n\nfetch(process.env.HASURA_GRAPHQL_URL); // wake up that darn instance!\n\nclass MyApp extends App {\n  render() {\n    const { Component, pageProps } = this.props;\n    return \u003cComponent {...pageProps} /\u003e;\n  }\n}\n\nexport default MyApp;\n```\n\n## Shortcomings - Help needed!\n\n- The profile page won't display user data initially. I am shrugging this one off as my goal here is to demonstrate consuming Hasura's gql endpoint and only rely on auth0's idToken to do so.\n- I can't find out how to seamlessly pass the token via cookies as suggested from [Apollo's](https://github.com/apollographql/apollo-client/issues/4455) [documentation](https://github.com/apollographql/apollo-client/issues/4190) and [issues](https://github.com/apollographql/apollo-client/issues/41900). The current workaround is to set cookie manually after auth, but it's ugly and feels unnecessary when if should be provided out of the box by Apollo.\n- the idToken is set/get in a cookie with `js-cookie` in order to add to the headers for calls to hasura (look for all the \"TODO remove when cookie solution found\" comments). It should be handled out of the box by `nextjs-auth0`, so this might be a mistake/overlook of mine.\n- login is janky when using a social button. I don't have much time to troubleshoot this either.\n- a proxi api route should be used to avoid exposing the id token in the client, as explained [here](https://github.com/auth0/nextjs-auth0/issues/67#issuecomment-581599845)\n\n## Setup\n\n- git clone this repository\n- spin up an Hasura instance\n  - generate JWT secret, add it to env vars (HASURA_GRAPHQL_JWT_SECRET)\n  - optionally add the HASURA_GRAPHQL_UNAUTHORIZED_ROLE var\n  - set an HASURA_GRAPHQL_ADMIN_SECRET\n- setup an Auth0 account\n  - copy domain, client ID, secret into `.env` file\n  - add rules found in `auth0` folder (looks like `upsert-user.js` should be above the claim one)\n  - add env vars so the rules work\n    - ADMIN_SECRET (same than HASURA_GRAPHQL_ADMIN_SECRET)\n    - HASURA_GRAPHQL_URL\n  - set callback/redirect URL in your app\n- fill in `hasura/config.yaml` file\n- ```bash\n  cd hasura\n  hasura migrate apply\n  ```\n- ```bash\n  yarn\n  yarn dev\n  ```\n\n## Deploy with zeit's now\n\n- Update `REDIRECT_URI` and `POST_LOGOUT_REDIRECT_URI` in the `now.json` file\n- add all the secrets (start with @ in the file) [with the cli](https://zeit.co/docs/v2/build-step/#using-environment-variables-and-secrets)\n\n## Notes\n\n- [How to](https://dev.to/mikewheaton/public-graphql-queries-with-hasura-2n06) set up public access on hasura.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatt%2Ftest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatt%2Ftest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatt%2Ftest/lists"}