Skip to content

Commit

Permalink
Fix headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevintjuhz committed Nov 26, 2024
1 parent 7151d12 commit 11b62f1
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 17 deletions.
3 changes: 2 additions & 1 deletion dist/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/components.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/components.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ function PreprPreviewBar(props) {
var _a;
const { activeSegment, activeVariant, data } = props;
if ((data == null ? void 0 : data.items) && (data == null ? void 0 : data.items[(data == null ? void 0 : data.items.length) - 1].reference_id) !== "null") {
data.items.push({
data.items;
data.items.unshift({
reference_id: "null",
body: "All other users"
});
Expand Down
2 changes: 1 addition & 1 deletion dist/components.mjs.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,34 @@ import { headers } from "next/headers";
function PreprMiddleware(request, response) {
var _a, _b, _c;
const newResponse = response || NextResponse.next();
const utm_source = request.nextUrl.searchParams.get("utm_source");
const utm_medium = request.nextUrl.searchParams.get("utm_medium");
const utm_term = request.nextUrl.searchParams.get("utm_term");
const utm_content = request.nextUrl.searchParams.get("utm_content");
const utm_campaign = request.nextUrl.searchParams.get("utm_campaign");
const initial_referral = request.headers.get("referer");
let cookie = (_a = request.cookies.get("__prepr_uid")) == null ? void 0 : _a.value;
if (utm_source) {
newResponse.headers.set("Prepr-Context-utm_source", utm_source);
}
if (utm_medium) {
newResponse.headers.set("Prepr-Context-utm_medium", utm_medium);
}
if (utm_term) {
newResponse.headers.set("Prepr-Context-utm_term", utm_term);
}
if (utm_content) {
newResponse.headers.set("Prepr-Context-utm_content", utm_content);
}
if (utm_campaign) {
newResponse.headers.set("Prepr-Context-utm_campaign", utm_campaign);
}
if (initial_referral) {
newResponse.headers.set(
"prepr-context-initial_referral",
initial_referral
);
}
if (!cookie) {
cookie = crypto.randomUUID();
newResponse.cookies.set("__prepr_uid", cookie, {
Expand Down
Loading

0 comments on commit 11b62f1

Please sign in to comment.