https://github.com/labd/next-sentry-tunnel
Sentry tunnel using Next.js route handler
https://github.com/labd/next-sentry-tunnel
Last synced: about 1 year ago
JSON representation
Sentry tunnel using Next.js route handler
- Host: GitHub
- URL: https://github.com/labd/next-sentry-tunnel
- Owner: labd
- Archived: true
- Created: 2024-04-24T08:14:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T08:44:44.000Z (about 2 years ago)
- Last Synced: 2025-02-20T22:43:02.612Z (over 1 year ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# next-sentry-tunnel
Simple solution to use Next.js route handlers for a Sentry tunnel to work around ad blockers.
Based on [Sentry example](https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option)
This works just using environment variables, no further setup for now.
## Install
Install using your package manager of choice (example has npm):
```bash
npm install next-sentry-tunnel
```
## Usage
First set up the required environment variables:
```bash
SENTRY_HOST=oXXXXXX.ingest.sentry.io
SENTRY_PROJECTS="123456" # Also allows multiple id's comma separated
```
Then set up the handlers in `app/api/tunnel/route.{ts,js}` or your own route of choice:
```typescript
// Route handler file
export { POST } from "next-sentry-tunnel";
```
Afterwards set up your `sentry.client.config.{ts,js}` to point to the tunnel:
```typescript
// sentry.client.config.ts
import * as Sentry from "@sentry/nextjs";
Sentry.init({
...
tunnel: "/api/tunnel" // Or your own route of choice
})
```