-
Notifications
You must be signed in to change notification settings - Fork 17
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
refactor(authlify): get authlify token from header #326
Conversation
@ascorbic do people use We initially wanted to support Is there a way for us to tell if anyone is using it during the build? |
@dwwoelfel No, it's not something people usually do, but there isn't any particular reason it would be a problem. That said, conceptually it seems a bit odd having the same function. Would it be needing env vars injected by us when it's used? Presumably that would mean it wouldn't locally except via the Netlify CLI: somebody running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. Just a few points to make it more flexible mostly.
export type HandlerEventWithOneGraph = HandlerEvent & OneGraphPayload | ||
const logErrors = function (errors: GraphTokenResponseError[]) { | ||
for (const error of errors) { | ||
let errorMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we only changing the function name for the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I thought of making a function to create the error message, but thought it was overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Which problem is this pull request solving?
The graph token is now available via the
x-nf-graph-token
header.This will work better across different frameworks and require less effort to support a new framework.
List other issues or pull requests related to this problem
https://github.com/netlify/proxy/pull/767
Describe the solution you've chosen
This is fully laid out in https://www.notion.so/netlify/Graph-token-location-876947e0084447b49df96ec11248dd03, but I'll briefly summarize below:
This gets the graph token from the new
x-nf-graph-token
header instead of the event when used in a function or ODB. When used in a build, we retrieve the token from theNETLIFY_GRAPH_TOKEN
environment variable.It also exposes a
getNetlifyGraphToken
function that users can use to get the token instead of relying onevent.netlifyGraphToken
, which isn't available in e.g. next.jsChecklist
Please add a
x
inside each checkbox: