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

Update local development setup with Ngrok for Clerk #254

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yamz8
Copy link
Contributor

@yamz8 yamz8 commented Nov 16, 2024

Related to #203


For more details, open the Copilot Workspace session.

Summary by CodeRabbit

  • New Features

    • Enhanced local development capabilities with the addition of an ngrok command for easier internet access to the application.
  • Improvements

    • Updated the development script to run ngrok concurrently with existing commands, streamlining the development process.

Copy link

vercel bot commented Nov 16, 2024

@yamz8 is attempting to deploy a commit to the Hayden Bleasel Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Nov 16, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • docs/setup.mdx is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes made in the pull request involve modifications to the package.json file for the api application. The dev script has been updated to run the ngrok command concurrently with existing commands for next and stripe. A new script for ngrok has also been added, which establishes a tunnel to a local server on port 3002. These updates enhance the functionality available for local development.

Changes

File Change Summary
apps/api/package.json - Added script: "ngrok": "ngrok http http://localhost:3002"
- Updated dev script to include ngrok: "dev": "concurrently \"pnpm:next\" \"pnpm:stripe\" \"pnpm:ngrok\""

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant API
    participant Ngrok

    Developer->>API: Run development script
    API->>Ngrok: Start ngrok tunnel
    API->>API: Start next server
    API->>API: Start stripe service
    Ngrok->>Developer: Provide public URL
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
apps/api/package.json (1)

Line range hint 27-36: Add ngrok as a devDependency

The project is using ngrok in the scripts but it's not listed in the devDependencies. This could cause setup issues for other developers.

Add ngrok to devDependencies:

  "devDependencies": {
    "@repo/typescript-config": "workspace:*",
    "@types/node": "22.9.0",
    "@types/react": "18.3.12",
    "@types/react-dom": "18.3.1",
    "concurrently": "^9.1.0",
+   "ngrok": "^5.0.0",
    "typescript": "^5.6.3"
  }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5f36306 and 9560bb0.

⛔ Files ignored due to path filters (1)
  • docs/authentication.mdx is excluded by none and included by none
📒 Files selected for processing (1)
  • apps/api/package.json (1 hunks)
🔇 Additional comments (1)
apps/api/package.json (1)

5-5: Verify Clerk webhook configuration with ngrok

The concurrent execution of ngrok with the API server looks good. Since this is for Clerk integration, ensure that you:

  1. Update your Clerk webhook endpoints with the ngrok URL
  2. Configure the necessary webhook events in Clerk dashboard

Let's verify the webhook configuration:

✅ Verification successful

Webhook configuration is properly implemented and documented

The codebase shows a well-implemented Clerk webhook setup:

  • A complete webhook handler exists at apps/api/app/webhooks/clerk/route.ts that processes various Clerk events
  • The documentation in authentication.mdx provides clear instructions for setting up webhooks with ngrok
  • The webhook handler verifies signatures using CLERK_WEBHOOK_SECRET environment variable
  • The concurrent execution with ngrok in the package.json is correctly configured
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if Clerk webhook configuration exists in environment files
rg -l "CLERK.*WEBHOOK|WEBHOOK.*CLERK" .env* || echo "No Clerk webhook configuration found in .env files"

# Look for webhook handler implementations
rg -l "clerk.*webhook|webhook.*clerk" --type ts --type tsx

Length of output: 293


Script:

#!/bin/bash
# Look for webhook handler implementations with broader search
rg -l "clerk.*webhook|webhook.*clerk"

# Search for Clerk-related configuration or webhook setup
rg -l "clerk" --type ts

# Check for any webhook route handlers
rg -l "webhook.*handler|post.*webhook" --type ts

# Look for environment variable references
fd ".env"

Length of output: 695


Script:

#!/bin/bash
# Check the Clerk webhook handler implementation
cat apps/api/app/webhooks/clerk/route.ts

# Check documentation for webhook setup instructions
cat docs/authentication.mdx

# Look for environment variable templates or examples
fd -e example -e sample -e template .env

Length of output: 7526

apps/api/package.json Outdated Show resolved Hide resolved
@haydenbleasel
Copy link
Owner

@yamz8 nice work! Can you also update the setup.mdx to note that you'll need the ngrok CLI installed?

* **`apps/api/package.json`**
  - Add a new script "ngrok" to start Ngrok and forward to localhost:3002
  - Update the "dev" script to run "concurrently" with "next", "stripe", and "ngrok"

* **`docs/authentication.mdx`**
  - Add instructions for using Ngrok for local development with Clerk
  - Remove recommendation to create a new Vercel project for local development
  - Add a new section explaining how to set up and use Ngrok

* **`docs/setup.mdx`**
  - Add a note about the need to install Ngrok
add domain to keep persistent
@yamz8
Copy link
Contributor Author

yamz8 commented Nov 25, 2024

@haydenbleasel u want me to change anything else?

@haydenbleasel
Copy link
Owner

@yamz8 if i remember correctly, ngrok dynamically generates a url for you to test locally right? so you'd have to change it every time you start work?

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

Successfully merging this pull request may close these issues.

2 participants