Skip to content

Instantly share code, notes, and snippets.

@kiliman
Created June 26, 2023 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiliman/70ccdf34894db0650aee4eed4bf2df98 to your computer and use it in GitHub Desktop.
Save kiliman/70ccdf34894db0650aee4eed4bf2df98 to your computer and use it in GitHub Desktop.
Patch to add header to client-side requests in Remix
diff --git a/node_modules/@remix-run/react/dist/data.js b/node_modules/@remix-run/react/dist/data.js
index b3b935f..58a4874 100644
--- a/node_modules/@remix-run/react/dist/data.js
+++ b/node_modules/@remix-run/react/dist/data.js
@@ -61,6 +61,12 @@ async function fetchData(request, routeId, retry = 0) {
init.body = await request.formData();
}
}
+ init.headers = {
+ ...init.headers,
+ ...{
+ "X-Remix-Test": "test"
+ }
+ };
if (retry > 0) {
// Retry up to 3 times waiting 50, 250, 1250 ms
// between retries for a total of 1550 ms before giving up.
diff --git a/node_modules/@remix-run/react/dist/esm/data.js b/node_modules/@remix-run/react/dist/esm/data.js
index 2727874..0e594e2 100644
--- a/node_modules/@remix-run/react/dist/esm/data.js
+++ b/node_modules/@remix-run/react/dist/esm/data.js
@@ -57,6 +57,12 @@ async function fetchData(request, routeId, retry = 0) {
init.body = await request.formData();
}
}
+ init.headers = {
+ ...init.headers,
+ ...{
+ "X-Remix-Test": "test"
+ }
+ };
if (retry > 0) {
// Retry up to 3 times waiting 50, 250, 1250 ms
// between retries for a total of 1550 ms before giving up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment