securenow 4.0.6 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/cli.js +4 -1
- package/docs/ARCHITECTURE.md +408 -0
- package/{AUTO-BODY-CAPTURE.md → docs/AUTO-BODY-CAPTURE.md} +3 -0
- package/docs/AUTO-SETUP-SUMMARY.md +331 -0
- package/{AUTO-SETUP.md → docs/AUTO-SETUP.md} +3 -0
- package/{AUTOMATIC-IP-CAPTURE.md → docs/AUTOMATIC-IP-CAPTURE.md} +3 -0
- package/{BODY-CAPTURE-FIX.md → docs/BODY-CAPTURE-FIX.md} +3 -0
- package/{BODY-CAPTURE-QUICKSTART.md → docs/BODY-CAPTURE-QUICKSTART.md} +147 -147
- package/docs/CHANGELOG-NEXTJS.md +235 -0
- package/docs/COMPLETION-REPORT.md +408 -0
- package/{EASIEST-SETUP.md → docs/EASIEST-SETUP.md} +3 -0
- package/docs/EXPRESS-BODY-CAPTURE.md +1027 -0
- package/{FINAL-SOLUTION.md → docs/FINAL-SOLUTION.md} +3 -0
- package/docs/IMPLEMENTATION-SUMMARY.md +410 -0
- package/docs/INDEX.md +129 -0
- package/{NEXTJS-BODY-CAPTURE-COMPARISON.md → docs/NEXTJS-BODY-CAPTURE-COMPARISON.md} +3 -0
- package/docs/NEXTJS-WEBPACK-WARNINGS.md +267 -0
- package/{NEXTJS-WRAPPER-APPROACH.md → docs/NEXTJS-WRAPPER-APPROACH.md} +3 -0
- package/{QUICKSTART-BODY-CAPTURE.md → docs/QUICKSTART-BODY-CAPTURE.md} +3 -0
- package/{REDACTION-EXAMPLES.md → docs/REDACTION-EXAMPLES.md} +3 -0
- package/{REQUEST-BODY-CAPTURE.md → docs/REQUEST-BODY-CAPTURE.md} +575 -575
- package/{SOLUTION-SUMMARY.md → docs/SOLUTION-SUMMARY.md} +3 -0
- package/docs/VERCEL-OTEL-MIGRATION.md +255 -0
- package/examples/README.md +3 -0
- package/examples/instrumentation-with-auto-capture.ts +3 -0
- package/examples/next.config.js +3 -0
- package/examples/nextjs-api-route-with-body-capture.ts +3 -0
- package/examples/nextjs-env-example.txt +3 -0
- package/examples/nextjs-instrumentation.js +3 -0
- package/examples/nextjs-instrumentation.ts +3 -0
- package/examples/nextjs-middleware.js +3 -0
- package/examples/nextjs-middleware.ts +3 -0
- package/examples/nextjs-with-options.ts +3 -0
- package/examples/test-nextjs-setup.js +3 -0
- package/nextjs-auto-capture.js +3 -0
- package/nextjs-middleware.js +3 -0
- package/nextjs-wrapper.js +3 -0
- package/nextjs.js +174 -72
- package/package.json +3 -19
- package/postinstall.js +310 -310
- package/tracing.js +287 -287
- /package/{CUSTOMER-GUIDE.md → docs/CUSTOMER-GUIDE.md} +0 -0
- /package/{NEXTJS-BODY-CAPTURE.md → docs/NEXTJS-BODY-CAPTURE.md} +0 -0
- /package/{NEXTJS-GUIDE.md → docs/NEXTJS-GUIDE.md} +0 -0
- /package/{NEXTJS-QUICKSTART.md → docs/NEXTJS-QUICKSTART.md} +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# Next.js Webpack Warnings - Fix Guide
|
|
2
|
+
|
|
3
|
+
## The Problem
|
|
4
|
+
|
|
5
|
+
When using SecureNow with Next.js, you might see webpack warnings like:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
⚠ Critical dependency: the request of a dependency is an expression
|
|
9
|
+
⚠ Module not found: Can't resolve '@opentelemetry/winston-transport'
|
|
10
|
+
⚠ Module not found: Can't resolve '@opentelemetry/exporter-jaeger'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Good news:** Your app still works! These are just webpack bundling warnings.
|
|
14
|
+
|
|
15
|
+
**Why it happens:** OpenTelemetry instrumentations use dynamic `require()` statements that webpack can't analyze at build time. This is normal for Node.js server code but Next.js's bundler complains about it.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ✅ Solution 1: Suppress Warnings (Recommended)
|
|
20
|
+
|
|
21
|
+
Add webpack configuration to suppress these warnings.
|
|
22
|
+
|
|
23
|
+
### Step 1: Update your `next.config.js`
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const { getSecureNowWebpackConfig } = require('securenow/nextjs-webpack-config');
|
|
27
|
+
|
|
28
|
+
/** @type {import('next').NextConfig} */
|
|
29
|
+
const nextConfig = {
|
|
30
|
+
webpack: (config, options) => {
|
|
31
|
+
return getSecureNowWebpackConfig(config, options);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// Optional: Tell Next.js not to bundle OpenTelemetry packages
|
|
35
|
+
serverExternalPackages: [
|
|
36
|
+
'@opentelemetry/sdk-node',
|
|
37
|
+
'@opentelemetry/auto-instrumentations-node',
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = nextConfig;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Step 2: Restart your dev server
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run dev
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Done!** No more warnings. ✨
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ✅ Solution 2: Manual Webpack Config
|
|
55
|
+
|
|
56
|
+
If you already have custom webpack config:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
/** @type {import('next').NextConfig} */
|
|
60
|
+
const nextConfig = {
|
|
61
|
+
webpack: (config, options) => {
|
|
62
|
+
if (options.isServer) {
|
|
63
|
+
// Suppress OpenTelemetry warnings
|
|
64
|
+
config.ignoreWarnings = config.ignoreWarnings || [];
|
|
65
|
+
config.ignoreWarnings.push(
|
|
66
|
+
{
|
|
67
|
+
module: /@opentelemetry\/instrumentation/,
|
|
68
|
+
message: /Critical dependency/,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
module: /@opentelemetry/,
|
|
72
|
+
message: /Module not found.*winston-transport/,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
module: /@opentelemetry/,
|
|
76
|
+
message: /Module not found.*exporter-jaeger/,
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Your other webpack config
|
|
82
|
+
return config;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = nextConfig;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## ✅ Solution 3: Disable Problematic Instrumentations
|
|
92
|
+
|
|
93
|
+
If you don't need certain instrumentations, disable them:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// instrumentation.ts
|
|
97
|
+
import { registerSecureNow } from 'securenow/nextjs';
|
|
98
|
+
|
|
99
|
+
export function register() {
|
|
100
|
+
registerSecureNow({
|
|
101
|
+
disableInstrumentations: [
|
|
102
|
+
'winston', // Winston logger (optional)
|
|
103
|
+
'bunyan', // Bunyan logger (optional)
|
|
104
|
+
'pino', // Pino logger (optional)
|
|
105
|
+
'fs', // File system (too noisy)
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 📋 Understanding the Warnings
|
|
114
|
+
|
|
115
|
+
### "Critical dependency" warnings
|
|
116
|
+
|
|
117
|
+
**What it means:** OpenTelemetry uses `require(moduleName)` where `moduleName` is a variable. Webpack can't analyze this statically.
|
|
118
|
+
|
|
119
|
+
**Is it a problem?** No! These modules are only loaded at runtime on the server, not in the browser.
|
|
120
|
+
|
|
121
|
+
**Solution:** Suppress the warnings using webpack config.
|
|
122
|
+
|
|
123
|
+
### "Module not found" warnings
|
|
124
|
+
|
|
125
|
+
**What it means:** Some instrumentations have optional peer dependencies that aren't installed.
|
|
126
|
+
|
|
127
|
+
**Is it a problem?** No! These are optional. If you're not using Winston logging or Jaeger exporter, you don't need them.
|
|
128
|
+
|
|
129
|
+
**Solution:** Either:
|
|
130
|
+
1. Suppress the warnings (recommended)
|
|
131
|
+
2. Disable those instrumentations
|
|
132
|
+
3. Install the missing packages (only if you use them)
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 🔧 Advanced: serverExternalPackages
|
|
137
|
+
|
|
138
|
+
For Next.js 13+, you can tell Next.js not to bundle certain packages:
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
const nextConfig = {
|
|
142
|
+
serverExternalPackages: [
|
|
143
|
+
'@opentelemetry/sdk-node',
|
|
144
|
+
'@opentelemetry/auto-instrumentations-node',
|
|
145
|
+
'@opentelemetry/instrumentation',
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This tells Next.js to leave these packages as `require()` statements instead of bundling them.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 📦 Complete Example
|
|
155
|
+
|
|
156
|
+
Here's a complete `next.config.js` that handles everything:
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
const { getSecureNowWebpackConfig } = require('securenow/nextjs-webpack-config');
|
|
160
|
+
|
|
161
|
+
/** @type {import('next').NextConfig} */
|
|
162
|
+
const nextConfig = {
|
|
163
|
+
// Suppress warnings
|
|
164
|
+
webpack: (config, options) => {
|
|
165
|
+
return getSecureNowWebpackConfig(config, options);
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// Don't bundle OpenTelemetry
|
|
169
|
+
serverExternalPackages: [
|
|
170
|
+
'@opentelemetry/sdk-node',
|
|
171
|
+
'@opentelemetry/auto-instrumentations-node',
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
module.exports = nextConfig;
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## ❓ FAQ
|
|
181
|
+
|
|
182
|
+
### Q: Will these warnings affect my production build?
|
|
183
|
+
|
|
184
|
+
**A:** No. Your production build will work fine. These are just webpack warnings, not errors.
|
|
185
|
+
|
|
186
|
+
### Q: Should I be concerned about these warnings?
|
|
187
|
+
|
|
188
|
+
**A:** No. They're expected when using Node.js instrumentation in Next.js. Just suppress them using the webpack config.
|
|
189
|
+
|
|
190
|
+
### Q: Do I need to install the missing packages?
|
|
191
|
+
|
|
192
|
+
**A:** Only if you're actually using them. For example:
|
|
193
|
+
- `@opentelemetry/winston-transport` - only if you use Winston logger
|
|
194
|
+
- `@opentelemetry/exporter-jaeger` - only if you want to export to Jaeger
|
|
195
|
+
|
|
196
|
+
### Q: Why doesn't SecureNow bundle these packages?
|
|
197
|
+
|
|
198
|
+
**A:** OpenTelemetry instrumentations are designed for Node.js server environments and use features that don't work in bundled code (like dynamic requires and module patching).
|
|
199
|
+
|
|
200
|
+
### Q: Can I use SecureNow without these warnings?
|
|
201
|
+
|
|
202
|
+
**A:** Yes! Use the webpack config provided above to suppress them.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 🎯 Quick Fix (Copy-Paste)
|
|
207
|
+
|
|
208
|
+
**Just add this to your `next.config.js`:**
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
const { getSecureNowWebpackConfig } = require('securenow/nextjs-webpack-config');
|
|
212
|
+
|
|
213
|
+
module.exports = {
|
|
214
|
+
webpack: getSecureNowWebpackConfig,
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**That's it!** ✅
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 🆘 Still Having Issues?
|
|
223
|
+
|
|
224
|
+
If you're still seeing warnings after applying the fix:
|
|
225
|
+
|
|
226
|
+
1. **Restart your dev server completely**
|
|
227
|
+
```bash
|
|
228
|
+
# Stop the server (Ctrl+C)
|
|
229
|
+
# Clear Next.js cache
|
|
230
|
+
rm -rf .next
|
|
231
|
+
# Start again
|
|
232
|
+
npm run dev
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
2. **Check your Next.js version**
|
|
236
|
+
```bash
|
|
237
|
+
npm list next
|
|
238
|
+
```
|
|
239
|
+
- Next.js 15+ works best
|
|
240
|
+
- Next.js 14 and below need `experimentalInstrumentationHook: true`
|
|
241
|
+
|
|
242
|
+
3. **Verify webpack config is loading**
|
|
243
|
+
- Check that `next.config.js` is in your project root
|
|
244
|
+
- Make sure it's a `.js` file (not `.mjs` or `.ts`)
|
|
245
|
+
|
|
246
|
+
4. **Check for conflicting webpack config**
|
|
247
|
+
- If you have other webpack plugins, they might conflict
|
|
248
|
+
- Try the SecureNow config alone first
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 📚 More Help
|
|
253
|
+
|
|
254
|
+
- [Next.js Webpack Documentation](https://nextjs.org/docs/app/api-reference/next-config-js/webpack)
|
|
255
|
+
- [OpenTelemetry Next.js Guide](./NEXTJS-GUIDE.md)
|
|
256
|
+
- [SecureNow Documentation](./README.md)
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
**TL;DR:** Add webpack config to suppress warnings. Your app works fine, the warnings are just noise from webpack trying to analyze Node.js server code.
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|