-
Notifications
You must be signed in to change notification settings - Fork 206
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
fix(clerk-sdk-node): load config on first use #1230
Conversation
b777345
to
a047284
Compare
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.
❌ The following Jit checks failed to run:
- software-component-analysis-js
#jit_bypass_commit
in this PR to bypass, Jit Admin privileges required.
More info in the Jit platform.
1451f8d
to
eb6386a
Compare
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.
🧹 🧹 🧹
eb4b4a5
to
b7d49f4
Compare
@dimkl Can you please elaborate on the issue that this change addresses? |
Currently in Clerk Node, the following code doesn't run because Clerk doesn't read any of the keys even though they are clearly imported, this leads to a bad DX and reports that Clerk doesn't work correctly. import { ClerkExpressWithAuth } from "@clerk/clerk-sdk-node";
import express from "express";
require('dotenv').config()
const port = process.env.PORT || 3000;
const app = express();
// Use the lax middleware that returns an empty auth object when unauthenticated
app.get(
"/protected-endpoint",
ClerkExpressWithAuth({
// ...options
}),
(req, res) => {
res.json(req.auth);
}
);
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
}); Notice that since there is no underlying framework to load the env before the Clerk imports are evaluated, the order of the imports and the We need to read the current env value when needed, not just once during initialization. |
b7d49f4
to
d8805a0
Compare
🦋 Changeset detectedLatest commit: 63eb73b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
afbb951
to
4c4626c
Compare
First usage of clerkClient can be either from accessing a method from clerkClient or from using the middleware exposed from the package which are using the clerkClient exposed by package.
4c4626c
to
63eb73b
Compare
Type of change
Packages affected
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore
Description
npm test
runs as expected.npm run build
runs as expected.