diff --git a/crates/common/src/integrations/nextjs.rs b/crates/common/src/integrations/nextjs.rs index 4ee347e..f80c23b 100644 --- a/crates/common/src/integrations/nextjs.rs +++ b/crates/common/src/integrations/nextjs.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use regex::{escape, Regex}; use serde::{Deserialize, Serialize}; +use serde_json::Value as JsonValue; use validator::Validate; use crate::integrations::{ @@ -22,6 +23,8 @@ pub struct NextJsIntegrationConfig { )] #[validate(length(min = 1))] pub rewrite_attributes: Vec, + #[serde(default = "default_remove_prebid")] + pub remove_prebid: bool, } impl IntegrationConfig for NextJsIntegrationConfig { @@ -38,6 +41,10 @@ fn default_rewrite_attributes() -> Vec { vec!["href".to_string(), "link".to_string(), "url".to_string()] } +fn default_remove_prebid() -> bool { + true +} + pub fn register(settings: &Settings) -> Option { let config = build(settings)?; let structured = Arc::new(NextJsScriptRewriter::new( @@ -92,6 +99,7 @@ impl NextJsScriptRewriter { ctx.request_host, ctx.request_scheme, &self.config.rewrite_attributes, + self.config.remove_prebid, ) { ScriptRewriteAction::replace(rewritten) } else { @@ -120,7 +128,10 @@ impl IntegrationScriptRewriter for NextJsScriptRewriter { match self.mode { NextJsRewriteMode::Structured => self.rewrite_values(content, ctx), NextJsRewriteMode::Streamed => { - if !content.contains("self.__next_f") { + // Check for Next.js streaming patterns: + // - self.__next_f = Flight data (component streaming) + // - self.__next_s = Script streaming (for