Skip to content

Commit

Permalink
fix: apply the same update to quick editor
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundhung committed Dec 27, 2024
1 parent 24181b0 commit 184d121
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/edge-preview-authenticated-proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ async function handleRawHttp(request: Request, url: URL) {
const token = requestHeaders.get("X-CF-Token");
const remote = requestHeaders.get("X-CF-Remote");

// Fallback to the request method for backward compatiblility
const method = requestHeaders.get("X-CF-Http-Method") ?? request.method;

if (!token || !remote) {
throw new RawHttpFailed();
}
Expand All @@ -216,6 +219,7 @@ async function handleRawHttp(request: Request, url: URL) {
// request due to exceeding size limits if the value is included twice.
requestHeaders.delete("X-CF-Token");
requestHeaders.delete("X-CF-Remote");
requestHeaders.delete("X-CF-Http-Method");

const headerEntries = [...requestHeaders.entries()];

Expand All @@ -229,6 +233,7 @@ async function handleRawHttp(request: Request, url: URL) {
const workerResponse = await fetch(
switchRemote(url, remote),
new Request(request, {
method,
headers: requestHeaders,
redirect: "manual",
})
Expand Down
37 changes: 37 additions & 0 deletions packages/edge-preview-authenticated-proxy/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,43 @@ compatibility_date = "2023-01-01"
`);
});

it("should use the method specified on the X-CF-Http-Method header", async () => {
const token = randomBytes(4096).toString("hex");
const resp = await worker.fetch(
`https://0000.rawhttp.devprod.cloudflare.dev`,
{
method: "POST",
headers: {
// "Access-Control-Request-Method": "POST",
origin: "https://cloudflare.dev",
"X-CF-Token": token,
"X-CF-Remote": `http://127.0.0.1:${remote.port}`,
"X-CF-Http-Method": "PUT",
},
}
);

expect(await resp.text()).toMatchInlineSnapshot('"PUT"');

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: Snapshot `Raw HTTP preview > should use the method specified on the X-CF-Http-Method header 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:35781/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","c75c0b1146a36ddca79e60ac0c18e02c21da9639a30bbf9d9617adffca5cf06691e444ea0b20d093df8228b72d9aebc1db8554da76550681b3b3fba3c592e3ec0629c543b85e17c43ff3c40889e0ef11b76319f3b7b96fc81ef74d6b4fa6e8a12dd5f4ad6e3a6367732522f525d13cfc658950977fd232d29914d85d48f905a4a6e2298f7e578c8b6863d841c8993b368957b46e20c8a85549e3731da022472a0d6cbe1689501d3211eab53b193dd11dad5bc2f5f09e9b77e09d91bb574d3bb80a9e29ab246d2f305ce0bc46af4ce93ae7bf74b613a6322880808501d1d38fbe649de5d240ed96d9b580af285e808988e058d8ca898b1f2a7f542d01cfe60a7a277920909e95df7a471e533f72aeccf315b8dfeff1b7d8f98f1c0053d6c3241be06bc1d2274523533ead98f322c76db85b01c2af090cfc7e3f640525607989b037463c1b09cb8eba60fc7dbe020dc9bb9bb7172a40cb8e2fe42aa0909e5123edbdbc8d83b843321449cf026924e5fc38a529bf2c3a7f640e150d106b1a74d734602f17b88032534a99d3f51ef6733b6954b6f8f99badec85a9f2044b6feadfa6f6012fb5ec7629e064f8b40d246ad8edcd8ebc4ae7f61b674c8b30ebfa0b7c3dfec879e44dbf7661d36a0e10d5efa58800d7c82981df01326622c8732cb6114a68f186d1e63e8979d141b61e259a688e0d8ea71cb3bff50a829ff3e2d6b6fb8249b4739a63ae94aebaad5b0b9ec702a55585dc4b9af92275e7ef6557fa41788c005380fae2402607feb818e180f858353e512636e712bb061d401efe1672c9a0fa8a4e70a0d16d3326d4ff6ba7e0b646b9130a6f423afa3bf60ae4f5f6f1307de94c26df014ba72179537a100f69f6d43ec00ae5d3061abc92b5abe431d8b2f132d70f2ac6dc4ca4ca650d1fa2cf16d1898d3f2feb9af2cfdc9648355aed6f1d0457cde90b1f04d21ce61f1ba7037bed789871bdc8987edd34bc223a57c0a2ca2efabcecc0688d5e146320fab6176c89160e3fd46274f94e93bee50bb4409717dcddf2b2257fd0ea18197b54c43135466ff6a2cf5d3c5f2a2eac84e880da55f1d41144b88308134cc10e3b73ce1e8a84e8395c2681d0531e9fba8ec6accdb39fe937c2f4186f69c63a4a2aa406cfd57bd8e3d205c473c4fd8de81b50d342b8329f1b3849983e267d26c76eaf51e60272c37a2ae308d313d3bbf32c808c9bdfcb0eaa351074c33ea466d09dadd2d8b3420326c20aadc1a667b9201b88af236f08274dbba751ae84427a145377dce209098535e8844cf42defd4b2c07abb9af9ef9575501af6afa0cb26ed01e58ebb31b3c65980b7bfcd89f8e6831cf5581657e29c6a3b9f899f927e1c89b60680d1e72f7aab39d437e6df33da752058360672fb1b481dbdc8f5e780ef35c0c946a920ae59a07162db0aaa8a1a6be854e6f60603779be9df6cba19112193a9f3819b76a295e70df2ad2ea9d9791f6d2fe7f9673b140a53569c06e42f492aa905a2a2d955c31c7d1be3f14fad6f8c4cc8eb072bf8fc3a78177bfd496fc6c3d95d4ef8ab83429c9c651c64ff24bc79767c1e949cb681c7d68379839aa40a23d466f12812f99147a0dd4bc20e646db4658b49f22789b2f0f880e954d63f689a2462a6ec734443172eb608b87a9d7a596e7552bd04ea98fd5bb4f8ec3c682f0d3ba89c2476248329efb9e00f142e8fa178708f1b43b9032e79459aeac4c5d1c5fe24b55de5b6e1d0a1c505a86c5a409007f55b80bed735a819db093ca3e0c9027fbbd678f3c2dac3d7e245e94d68e13ab42ed24e7bd70e8993df60cefe3d867cb033e7691d7a22577fb2c25b8a433ce5f9e761e276a4fc4faed44852df2e02fbb4c5473a0e52ea3e24a2da57c4b97ec6f7f15e53076e285dbf5d749e6420d97ce5c12c59038f4e3594d72b9d60f1776afac1468769a087ff38c60b4690d9abb2f08e4ac5d1b5cb20e447ea29e02199c15be625a9ffd06ff86c7b1c9af35763e98e0418aa63ad5dee371774b94f49b293e9381ee666ba572fee038fa860286a4d7e58b9a6a043445cc87cff9cbab2eef64523d40edccd739195e533cff9f0777d56896e46901919bb4204b3140330d4846ef2b0c94b38f86f072f6fb531d04f0fef0f81d63ea24baeabaf7134881a609606889707c8068458a429742cbcf413aa4d8e59b05f20da4c4833d8e20ca750610fea0f66571ec869a3a7742ef55c2d0321f70cdca93a6be6d2e32a3b3830590da04ed846f5f8e29a9e1483aa4b30b5891c882005d17fb7cf4a4e5541f09c18d0d0eaa9049dc438e41be943fa5f59455de31d900cfba35ed55e65e8644921e41c911cf89a53e833715e8eb9fa4e0b1cd5ba67ba520448740836866189133eb98c204a8cfae58462efe7c2b387d40f0017fd4c81ce3788984f3d15bdc484a42a8893ff44c8b125b971cb237ae9d5b0bea597635f62369edbecc0f2071f350917f53b8e05f5002c1429ed88c90961698c3394e7869112fe764d0138d1a0fda7b59a6dd612cf7f08cfceba36b3fea906cdc9d6a4db893a98a425754baac77870f59af432d23ee52fa6c062b4e1c8b57687989600bc4b55d35e984d534c384af286f279fe2daa385465d5959c9029ccfd414b878ef5577bbcc4b1e39f1894bc74603f0f1aaf0101e23bf2b2150ce82d4984855b7bac18203

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: Snapshot `Raw HTTP preview > should use the method specified on the X-CF-Http-Method header 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:49283/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","0ef3e6180920154c01d4d11ee60ca99a33b7aeae0bb263552f2395e908c409f771e794db4ac287914111ce8f41936dffb9d10d517ac8055e1601d0a688a109094785c89dad6e2c2ac495172ffac2e6c114a1364fe98072d1324e893194b14e55f4d559dbffe85d96a2a38fd9e3686c093e7387c292b59d8ee96e675c05358f26688eb512f4052057bbd4e8823c6eb6ef50be37d47ffbc1e80dd1e48a0ca8dc9df242a03e51a6afa34eadae83ef21916396997d206bba5531a375812c67dbbf41da43f459eac7251b4001bffbc22a15adcabfeabdb53e3b94d5f4531a8ae6866e99b8dc339567388f6f113dc3b34374331a750e55706db0d63b265513eb51cf6ca701ce36fe933a9be0ce2b4dad57e1ce0b015607fcba8b97bad83ae2906ab8a6c230db83019b6c488b23f5bc70171f883f35de39c7e56da7ad76ac0fee4ffd2ebcb221a7bdf46d1fe07380dbdfbd9b67564da9f7e6b17ece047d7e1d01c1b2423a45c812b0603b6100e082735a5ee701cd1219e57feb852794f0e31db24ac25f49a5aa4149394625b900c2e422c3920f18834e39d5db5163c224b8d347fd41f44ebfea38c9a59c83a0ce5e0a942addb8b45a2e35787cef691b0bd3c1edc95100be254e3de459270cb2e70faa933097ff079a2e4c54129ab9ddfa1c98aadeec5187ae24c961d3cc2f4eb19f6c1b9179949dc4a09984189b4001ff0e4813f059a4906a18d7502a45ff7adfaa25cfa2edc8b712f9c06a5605b6f8417a1231dad7b9a5fa8c8f57f3b29d25cc0ea14ec927da76595c78e781c2d005814ebc358657db5d336178bd27e39d3eb477bfe033e3394f421205933fb46bbd02930e4bc1cb42936eedc26dc7fc77276fcef49b934d8f7e4ab547857ba1e3bafed0c0f826b6dfe74df4065edf113476b105a97139b7968054284575c4f46eedd73a5cb131da0dddc5623623dd29de8470d5527a2381523d153779be317478d6feffe6386f9a4e23719778b3d66ab358d285e6e0c6af4fd2ae49660f6134aac174dc2ff2fb73b140b4c159148a06743f18dadfd6cc79330e216f3dfb581c4ba35bf7db45fd8874db2039f0be2fd5e5e4a1e4260aeca7323c53e603e7e84678aca0fe131bb9ff809419c9fd2dca8a0dd52a1a9c54b4147c6472e51291c2a3e60705d361903818b205b3175ad81c2ba076c7dd52bcadd00ac6103707472a9eca5f36877d5f2ef0e66adde61218bfa4845e2dcb5b917d8129d8f4daf4f96364a8a43339b1612689c898ab519cb196253f940ed9276e600e11481fb3936e764c1f5e934921e8cd2382960813b21df9efe3db41be7a6a67fefc91da7b6e1875a168918a9d07da0b776d3f54d54cc9e4be05e7f590ad974f94ff12ea7483e50a602b6f5e485e3b96079ea18daf6953e54b153c5fc2623d6df10632d2e84c9024142f08eefcfa7b05c74fd033ccb3f209ebbf43dec29f7706c785a5d0052d8986854fca447c4c4840628b2f44745afe48eb0f3b34e85d750974283663e058cd40fdda0377c0917f142b6f0958f2d2670b0fdeba3c0a36d61a9c565c78ee6f9554789ee6a7ddb81b6c8eb2f146026f1694bcff6500ba3e7f6f4ce292e0c98922d5994d37aa3205a2442c76688b75bf1ec2971de09a1c852d8536d49393290405ff4f5ef12344cc10e09024e3ac2a0b04463abcee461fa8efdc6c37473f432a4ccc0a376c15cf4d1f3ea8998e7c6b32fc7b79bc4b71219ca177f9249182cac7c7e1335a5cf9e0d300496e39482ffb3d6dda1e911033cd4cc8e26fabfa0d0a05fc83e340f30b4fcd6a3fc14f8a95eff52699fb6598478753f39395891cc06bea1b2e86ec7a0cae675a8114beafb957961a4028a5df103799c2324b87911bfaac91487e1d9ac502a7dae5f352c98d1b811167401eaed4a10b0e94a8f2799b37075f071a74399c9d74feb026d6d79d9fc542dfd009cec06b06ffa444be8680f4561bdbbcb4159eb2c9305ac0f14b2210ac97fdecbca1703d14ddbaeba230eb3de57ac8a99a46ea90e39fa31d23d00105ae6d5550e35e93e4b35efe65e1b19defd98321d9db38dcfe3f7b6c55d61b00954854d29c2e724d4208f9aa9dcfb9bd1066809099b956c14ad70722f037d511f66786aa92d128bbc55c3ed25defeda83211827514b5986fce1d1e810989178d8284d71d19fad15e199e8b5935de3dc4b2f678d69ca992b1b3b28f802cd6bb93f9b69a5e67e26630eaba063c72d9d4bc7f28e81b91b227d74ef9e85727700fd514385fae54634182a1ed434db0864b8e35af7dcb332d0b9181eb9111be98da123a70b0ce16dd2dd266b8ed3fc3a02d184c3d1cf91e3738a2b60e32faf2d6cd13dc97a1636476e08c050ae2301d71b0e6f0acbdfc31eb20edcb269b1f24eaa4be90b64a4c3902939b5fcb8d75cb03a817ad28237b16113e6ffe0edef3bdd0d9ad760eabcec58ec686e16e006dd106f1bc1399fddbad949745dcd849ec9672ab2da17273ca5a648dcba744bd49f6468ae734ca10e3b4224337c13dea406db05c2406f909b7e42fe57a137dbeaf876024fb010f6e4f804d45cc0f4a93e55131ac06b09af9e0d1f03623780f30c30e7f49c7407bfd31a667a90d6da311a9d94b3f60a213fccc9d13bed240d3167ced037304bc5a9c29361d1a89d57c9ad31b00be9d708911ace862129a6529061b180

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: Snapshot `Raw HTTP preview > should use the method specified on the X-CF-Http-Method header 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:62776/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","4b35e078cc24e281be3e5c937dfa0d129249f2748437fa34cd4fddabe1307556a67b9e6da95094b76d94271c5a3785ab4a695f3a1dec7e812533bcb5015f9d37f6a472b151fe20d6a6ee71394c8787147d293d58ea0cab645f04c1c86dfddded95acb9087208468a94c09bbc0bcb1d4c0855b5bd195437e6f27cf09554df424b629f22081278959f47e640bf184f7db2d4cc0f6d5f390385430cf6dad2dd0a91d3939eaccdfa9b23f31a4381072fc3e2db6f37ae9c64d343ff1eb5dedd3648870bf28e1011a3a79e162d1fb8d38c9c7892f0bf0be411b2b7bf6d1ee22c9b73ed0e7108bf7d51349fc98caa88ad2ee6ea06eebabf655607ef2165f5c2146d13ee4016d81af2ac63c838439cdad8daa473010bcd9621c1079a6563378f40c427388f68f711402148387733e55333ac0fb27def2d0961ec9e60205876cf0b9340e0dc4157c158d9272ce7215072e391f47dada8be0e19bed97efda4561278cb6c5c08f76f9e8150beeda59547a0acccc2633ee4e938279f3660db83ea03c502d54268f6ae0f515908c8ed58723ca10b69f91d81a151e120bb062793bbe7cdd1cc11cf522038ca964d902fa6821bf1853581df7b13038c587aa8bd6cf83a0c0c33809c287fe133c61e11a2328fe4915ca29cd0c4199d3a5bdf81bf170a741053fee28b4f2158a231f05a2b607888584a61e9eb40a419ee103b25e3caf0d089478d560dc90f6e6e1d346406ac47f6aa4ecd403fe38a7bb64915917d4f62cd6031bacc03b800fa16804cac8dc7835107b36dd0ed33167baf182674315c4f8838131d3cc0bbb9154a02d3d7b50da238f78a6505000749d83df19f58fb954644eabbb20fac50ca88023d3657a895bfa34b19f1692f2b6a4bc4e17a3df50d5cd1e9aa536b5a65a5a7c4a941000f90ec376d9dee3365f2588973b3801bcbe1c46e97fbb00839685bee1107c765fa75ab3c54bb6dd87f7594d089480f7b670b566da3f4b7e79bbe9c29005bd44c838c8fcd35c2ab043292b506a2b2c69f7916f3bf7e7a46f16dfa3c4be32e503521a9a115c1f446746d37a9b13e4c8a312bb69ed9f025555fe6f3c2c23d31c5de838f987bf99b91b1fe338be1f3bedae071ffdff18fea857b3f6186f39dbbe2ff9e92cbe8d8ccaba933f09e38c9c8858f6c3036bd961500483c7975c0b13cdf9b951dacc019c1bdfd5c8e55f9d82fb55d77978e5525e9900873316246889420afd72d9cb893275da5d2f36d533fc36fda81d1349cd9ffbbf262f0a2f681b5faac6d17ecfe05007a567e560b972774361f23b0211301d59cd3a020753ab71059e1708be69543ae68712ee56a9c7f10858ecbf84cf88719a7b9f7858a082417fa35936b9a19b8883a77cc8230991aceeb12e9a2e1f22efa7dcbccafa081136d79dbc7b50c5fc9157efc88f8f9f02e936ab4003c86b5f27f36a96f79e2cf643761724115c9f57963934cf106db280c033198f58aa66455874f7591f17f02e6227532d76a88570a768a32d461e5e61b2305ea8be391acf53869b1ecdfa1b201744173e11d0a5a4ae92b5d95879d009513b877e43ada1c0169a8d2afed8943090ccb102e71ac6672a6eabf0ef2c75a20af1fbfee51617aa0df97d2d123bbb284e21d048eec03d8b76a0477466ea3d4ebc505300a09bd212a0b06b59dac787a290d1f4630ab6bbebc6d0a58894f0259f8be39b10976e9af5589bfc01f8a266fe61326eb7b685ac5e4616d13467cbe45c4affdc8534993dcec4a82ef77c2a77833218c5009fe8cb2a2378a2ded9b5655d3f162cde9e40da9dd8512f8a94cf340824a47826d3d426df2f59a7de9390e0b7ea6e56bb29c71e6994d98e666fb3f9fa313456e7e04a01fae23717b251f59791bb6b93a1bc2aac2bd479a532aac7b14140a30bd3e58bf4fb3a66a7e196a21313f7ab97ca9a87e2e5173c0ce74743e85649b50fcca237550b8f7200b257cc0b261862b8b0b9a957d13e2e50338cdeebc6eb4b06bb7cbda0354a3e6308181e436a9ccfa523d928160686ceaaf6ce5fe8c7780b109d9d6f184212a15c1490fc338e5652614be3c35c6224c09e50055e3cd286edeafb417fca2b04c474e67af05bea429188afcc04b74a19c8d44fc22b0702c42a0306a5f27091211c28599198a4200556a5cc7db539a31983a4d9d53459b8f3cadf6a82914e5765fbb80da508b68bc58b007d879710e62d816820500f8fc08d8de45913f8710bd273e324668cb6249c15b29b2eb8143d383dd8b0118fcafbc9ed9e57090c50c027f193a787608b1ca5516e22c874510c34c2957deba098629819437cf37d33dd062ebf4991f6509c793daeb94852f85efde7723a9fb3448dd917591f22628a149d17008fe14433e911c070c773ff5455a977d5cbc00835f6737d935f631ac5ea9304defa0e2ad73104d3ad34d696669f7c54f2fef1376f8f4125a32bdda488419709c9ebebf15f662ff4f5166fa36f4d139b7730aaafd7f39d63a5d60d7d10769a42b64f7a90ceb9847b70e28e3fc30a158c067f2abb69721da0cfb8824bb6bcaece544d4573b9b4388189424424e01e25f5946f1c02bfc15b92f7b638060f8d8cca04fa9490b8bb6181d3ac66e55d746d237315f4659c5e628e79ffda7ec30b1767d5e7d312f378949ac9aedac0b5dac5048be1e27c615ea7080e6a8c73d10be29882

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29

Check failure on line 488 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should use the method specified on the X-CF-Http-Method header

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:488:29
});

it("should fallback to the request method if the X-CF-Http-Method header is missing", async () => {
const token = randomBytes(4096).toString("hex");
const resp = await worker.fetch(
`https://0000.rawhttp.devprod.cloudflare.dev`,
{
method: "PUT",
headers: {
// "Access-Control-Request-Method": "GET",
origin: "https://cloudflare.dev",
"X-CF-Token": token,
"X-CF-Remote": `http://127.0.0.1:${remote.port}`,
},
}
);

expect(await resp.text()).toMatchInlineSnapshot('"PUT"');

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: Snapshot `Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:35781/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","cb96da2da822799ac1a5946f0075ecd1478fba96d83e1dc2433fff2779f995352f39a5c28cdcaf5bae9500c3e15350a9dc35c8d01eef77f1dec0ca2816329a4421dddec88e15aa358d4ce785ea9cfa774c6f22d7601542b5e1ae8bbe38c67fdf096c4ac7af854d84c61b8ec0894f4361e71bc3b2ccabcf7b93740784e49514a1e8023710f84377353f797c34b862abb707048423f265a88dd20b7bb8023e547708c17364523fcd5633af043fcfb99c6fea6d6d560dfd3b625b4be85d6682abbfe42a598b0bd8ca5f1cea267e9f909fa14c34c34e8cfb524dec15ba5f8d2dcc159a57020a31499181f6be63c4326f7a6c97cc96e49e49aa2ee077e9335d2ce0233df2af6ffad3aec375d81796dbe5774d3a15f644f6429c8aaadb8ea7176cdc0c9010b6eb8e64addd941ea124d3b286b3fd4cea4f62833f64f0e44b46121b9bcadfa62f85e365621aaa9e1a3412ae42ace3269dc7349675273c4b31c166a62c097b4e6a425f1d8e45334393639bf347bd68103962aefce2655a0e6d25d47b935aaa1830619e2760188d163d19969e4ddf7e62eada797ec64c0dc1cb548aea47fb11ad82d17d7bd15c100f275450e90995f4472664cfad0e238f5063dad4d4e8ae337f4a94850e2c3478ced8629d218a2e1d7b9d6fadb427e18ad5c2cb38a66985b46745b3813fdfda89aea6b8ff4b6cf2674e9c2b73b74370a2b69511034747ab907ad1c07acd060d6d8c912e92748ea2083469be4c1537850980ec94a9ea44c8a6698b7ce019a06a4d3b9eee1896b3e1806fedb6579d1c24fcdcfe80253634a4a558321d888da2181aae303f9a595e53646201c00bc12daa943560f8a03aafbe4b29982df5447c95d9de2b8f851420bd89a5ca74e7972230e14ef0b9ebfa8da4372273678401d2449a7aa228a77ca267b84533e2582ae8e433d7d5647cd65a32fe4797b6c0ac7953b117f6b0e65630e8c16e46d667e5a546a2ffb73f0724566e07cc09d3163831489392f51f2c03ed5b04472284fd489ac331397e79249dc3b8c9fefbbacae94f90dc8fc1cf57614b7d9d694578b850753b036f764f8164fcc81667a6afb4d1ac1ce3a3cc7466dd7bcedfe08874b633490b40a52d29be71f3d1e56d95ab7dec0b9d645e4c2ebbf99c637a643a947c5d89e64116bc3a8e0a5647e35bd6c2b918ab6d54767059178456cc70b8e1a85f307d94a5e06907ca88243fcad1bba8b0020fb3300a07feecbe22099bc123961d4747ec70f21d887c08db852301a575b38f138edee9d7ead68341f573faea337443d59e2a9c850ffedd729d763acb9ab0f4bc91d8f3d99645cab9c22fffd11f92c915cbccd51d7c0aebc0d4596fd6461f3c83a77fcaa7ed62b3a706c2b52716d989ebcb8f351f7a70c23821bc2c2bf480906b2a667f14c3e80989043998d4f9331ae7f73cbec318b0cf3537f47d10621177c56f8e896cb7149e9c4c0a2606f5fd2b998686e316ad39a0c7e369d539206efc023bd02d912ffa1c04515680c49b38fed2e02791863c5ea361cb30f373dd45e96bc5111cb5b66f6e77903409699c0d2e328b0d083d1c30c1ae3d08f5e1b486e30ed64d5ce75f3805b5febaf63e570b6c7ca88c263cb7656aa180441e2c720ef191fb12b6f7eca25b8f6831b1cb46f607c7292a5e1b9e477d913ca155ae0360a8d636a04432794d4354670649e8aedb36814ba55da54874d1ef5985cfad3cc7e341f1e7d7683e0a1eb971184b53df329a11cbaa65ecf18054bbd3655e6b17acc4338a7a426bf0270dfd4fc96242f7af6bdf743060338de5f37237872ae8a192017992de1360513ee8e3d8c76f8326a57facc77e6b9800a029e5c39131ee6892fe98dea6c342392da42a2fa4c24c1149be749d763b0d84f7d4c8948a88c960bd289100290538b5374521d79b6f8d095a69c7b59ae0d1dc3c176c81b195b530f07a06f18ede53e1e25594973d324acd91e4ff50b81f75008c564437b3e0093143dad86122e262c42bc2abb0da0858c03fe7f355e47052b24fb8984c17535857f9b7cadd0a0db408abf24216bb685a94210d5aee6399819f6835765e8b1fdc76cdedd38571253f98029e5111b5cd4d68d9ee1a03340e644e9a0c8d7f16e7a6ffea8a027dca003066c780413dcd6fee76759ff35c0d5bf929d83f66f5af8c74a86657870ce6eb5e8c54b56c1ddf0e9a28e545ff5695770b19d5d04ef156462b75f2a80a3bc8b3946f78752c77e46d2a5d5b240247809e00dfebe09b21e9f63eb6782ffb648ac4bb77426b1db4c2ad5b78c3467a75f05bc5b03c6242942e0298a9a5b56d60c05791d648790f1cdcd38f0826bc39bd794dfe78f393e419ac731b5a724c735b7e6d025805663fbc8ab0e98ec5b97488766d5e45799be1339f287cb11eee776b1d1088ea517ec486e6459d2186cc235f52456c6142b478d128521069980330d4156122be41f9feaed183b66e84de636826cfe12c65989cfff6f5003c9bc0951cc8af49f969fdc5c59958b2b3e05c944a7c7f3085c086398d9b6306d1ed41234270a087acd9fe97dc9793c54f32dd8b7acdce6a170d39daa81ad4d97b5bc923abdf54d011e703902d64541e10fb390bdba4d1038089de2665cf8a9df0c53301f73090489424a8c9d444de46377f32a26075dd60ba293b3da45bae41da8700a5

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (ubuntu-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: Snapshot `Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:49283/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","6acb42abbbc0f50705b62b2063bb327d4b7f34e602ff9ea840e6f5f0add3657e2a054ead3c58414badee277f787be77fb0f1cd5b959edc53b06a35344620b0c54db3a6725885765ca4f14977eba637e378acdc255561cb681ac58ca2ce95edd09dc8830102a33b5a88619ac19a3eb959c929da45e7bd434e8a7ce9c666345b1de4d0562c0b5578fcf40c23e2e4b56f3b9d0d0aebdaf86eb7203693e9474ba583b7f94e7d21c6f0f4d81ed0f97caca7f664b72fbcd9ae1e4d8ed4cd08218bedd041f6dd6aab2b5e3b27b6218007e169dfaa9f90b7bf0cc8fd644c26b4dbff16fd514bc354947fe0f70df8014f24b7f1a85c098b66a3ba5fdeee0c5fc0f9bcdaea3402f4f3680d118baceb5c8d48a918a8f768998c1c47d2901f9b4d998bd384ec075828c88ca158079289fe3264c473c43f1ff99a7c97155e715eb4cb59fb39b0078388fae6187d90bc99c0ff4802eae6a156eaf7573bf28d148c2ba4b77bfe455c82691ea9e38992b728a5f5ca50a1eab9bb6509b8deb8789f23f56f2ad1bf12f7dc578ec0b2d3791731e04d3104e27d59693c61ee39b49fad1fe1e41603100661c18ef8e82874de9fb76a9680125bd1eb3e5d40dc43dee3dd4556ebd3c4ad867fac2ee754925f20a29bdad622217853b3ec37ae7b76a8e0a3defbfd80fb38d391a4acdf02b51e3b4121082865e08aead479e2f7143d5f294a8ae26240a7376c2f3e84d7c4ad60e926568672763b52e1fd589ae815f85fee56981c3484de1a6106b55851cc03efb3041e7e4448d15230a282ba8491f587239fdfd8c364025dfac9ece78879251765132cd7777b1a1294cac51abfb2593317a87693cb80c97f755eb20c7a87149986c88ec7942f4b28d825eeb9367b7fccce03185041fbc6795d3f016805dd4e30b7ea4314bc480d98aa99a939578100d135a1ef7f7027aac5295eb845ee880d6c45997a94bcaaebab743ebab23527f82d2b64b7ec2f1c8858d5af06f08d7067dd26a37ebac6dd9d501c8897b650494bc0089068156fab6054fedf492c7feb1e9b38620d614cda0d6714fe098c4d109aeed3e6243a5bc2147957b47cc8f7bee70fa3323400aa64e45353267e4027d35d5965ac20f9edeaee1f577eb1de28faed66e63c5e66550369724fcbdb68200b414e5ebf836d194ba53e5c9ace52c2ae6d5567b6eb2cd3935b7c2d91f629c3ecf8959b32c8eb43d57482a0454664f07fb1d4331cd9b0b7e9ee1aa533d570ffda5548d30f55f20291391939c112deaa1334357d95f4704607f8a0296faefc041db6bf124ab167d2a3ed9cf98241836f8121b218dc1376617dd500562d9137eeaacc66c2071aac87db9002585753bbee68a56344caaa8ed2819dbc4e5a0546c729a7448d0ef614b2b0c99e9fd4d79267c5d4a9be2d2e6ad6e3f621490b650ef6b035dfbeb0fcb6c06a751eb2b1f0c5ebf040dc62a0b267071a919b7356db3e72155f8fd65b0677bcef7258c5ce926982d748649d5b7685f47c84666680968d087d0f61f6f3efe54775e5e512c5f05a66f80de74e4127dffcb8ad1df45bfa9d2d9b0df3a9a36ba9833e555b550ac37e4ff995c1eff05559bebb70d23dd6ec7b8285051684b787bdf7e709bf4b3ce8f218d1a518450ffb4ef45a11abe14a37c46adf920e745c170890fd1b3ff19865add42d49948a71ac2f0f5adc9a2ee6ba1f7d0722e7c193be32c3b2dcd4af1510eaa90aa0f61c4e7c68f05b35595c30fb13a7dc394d4e861beea2c57cacfd403a9faee825323b4d9c2d547ff0cf81893e282c4c33b0da4ec6edd936c5e174d39716cbc2cbdff1af503295d17c81f3ec2ad421d523f8e76d795d081bb80057c3c9d446a141eb3c47551e6c918d120ba3995025955da82cf415307d9223d5bc4bcdb295931f5c2967b32e1ae4628d1c9b2fe4bd6101f53095aa63168c84ff258402b9ce7f09d51137c6ad8da341d95c31b6229f5a5e2eac185fed5583093b4d700b9a801fadf903d609947e2a4af29b38474a01d146c6f6a7132e65550e0ecf2fa5f9ef40222a9cd70f3c93b3e9a010dad9269be1d2c593fb26a059c17b9dee498605609fb144811e9e86be830157d882ce94376d252ecaad4c13359c78bae4db73f40e9c14b2da1ee59de79d39949486f1e23daeea22efcfcccab15bde581ef9d4cfc67a4b9aa41148e4e03747f5009437369b69b642033c31c5080ae5e356de2a2714e2d3f599ac514897a5f79aeb80df79846b07255ee949caf20ddb034a9057d971a085c136197b7e25aa4ff199e56214c51dc3778e9a28075d573a730946db14a7d40f40e5762137fd9bd727acc1b1161e40208fcaebbdf891bddac42897e01f70d430331c6ecaa1801f6aa82b69e08ae40e75b51062e9601d0135f5aba1e108a39deda8d15c281d72887d97eb5744250d261ebd81f2a329a4e4d20b61e23e8e57dad6ff8d8a8c3ed7bad6599555a9e3430b2db2c7f4d0e718225cfcff0752073c73125e39b593e4fa63a33232d19cdcacd06ee0244ff3f200596b5a155d5f227b50ab34b4ab590bc0ba7a446775eb9a4c262cf36178fb703d7c2ef72befd16a2d4d136661513b28c86c9fe8b46676440455adbae2971bd007fb678ecb3dec5dda5c370f5dcbb2f97ce4144be0e0556f5fd71386550936ce9b57f4e30fb7368bb986b12d

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (macos-13, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: Snapshot `Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing 1` mismatched Expected: ""PUT"" Received: ""{"url":"http://127.0.0.1:62776/","headers":[["accept","*/*"],["accept-encoding","br, gzip"],["accept-language","*"],["cf-workers-preview-token","64564040188389b7d30a2011fa2a7dfbbff602bc1d9aeb75c45a6716beb9b6b5067e04065577189ed7b7618233a3a7a2d6fca3c2de6998b722d096155e8778ac03c34e4b89432f63bcbd38c8b84fbcd5928dcbb7b4769b888c5eef78bb58cf2461320e89459240cbcb01d3c9bcc7420c29aec46563798db43042edb5ef8e53e224ec78a5097ea5b5c271e4ca3158166d5dd32780b3ab71e3ff15576243f1557e3d09783a10cd8c553bf086c84e8a19fd0447b7391c390d5ded0247bcb45b4bf201731bf5d7577c3b792df361878ebf3c2d93d91b217e4798fbfdcd54de48947021944c291230f010249f4d81748a116a7d63f574e1b554052d3b3747ab5f390deb976d2a2fce46015ffdc5a39028eda826027cba579faca6cd3baedacfc0365f172c753058d00fa3d48ca6e066fc7bd986af6bfe239b2434bec556de4a79a4ad4f4aa92af5bcc540cf0d8ef0f172486642764ad750fc3043ca1e69a38306b293b9c18dcdc98b6590b2b2d33dfd996f0b38e36ae0ca6172f7110c00acdeea4c7bcfae4c9a9d519235a751a02fb4baf695f49b761ddd71a197dc8129211161d1066adc9d797d5876f191a871eb6b8fad5e2f15ad819cccd8dba03baa62aebe96654efd55b43aa69566c8d582d2aa7b8f848cd5fa501572d305dccfa54306faea1cc07fdce684c0c450ca816a706f050298a4c12e13271c37da3408cdd9171a0ffec30310b3a07c806edd38d3e4a590e3c65a481d1a9a74f5414bc4aa6323455a7c772595e635f668a930ecb8c64b369f7744c5737618ad9e5b4312530d58958c5c65e9b08e1518731b06ca8c725bb91b12a962fd9054a1c521d6d604cfd5ceacab4da4adc109960c0bac6b20dbe35525dd8d8d0531a37ca778b2d8bd78aacb846b3c323a48e8df539c1f288144a70ad2825d0dfb57073e0cc37882cf4e12926011950a99005eab553740358080983d6a33f1671bc60c1c43b781b82fb19d19d5c85e6d7a6c974fb9362a3a5e15939561933d9fe282b557a2d88729d05527ad24f1ef182772a1a15796bd945f5b79db639389b73da8566d1a539da10529502e248528e3e36b5e23138ffa88ef34f880aa05a0fbde492364488d831d9d477c569ab9f0cf3d1cc3a0a33257a0e0f6895f78d44fd06e859b1d886d9383b033e5cbfe129b9bcaa599a565127ce80e40e9f531c5230a04ca14a6e2e8d26ef9df1a432255e63da8fc207961342eb4373cbd0a438a1bd9dab275bef8837f428bdd54c7a01ddad70e717ea8a41810084d5171363cf0c8c6cc908126e11472f4c81951e845045e2f9ad0012986e81abe5430b159872f3c02416bf6b571bc88a882ee34bb9b18dc819b73096568aefa4b608a74b662c66674ad4c12b7e8cfd7c055c9a26a7cdeec0414fea187ef8d8eae34c28ba28f8f46bba537a4f1d902b6e381ac3169aad0211523e4b1be19bd7c8d2c21f2be1f399740239be13a2a0347716d5c335aa19d2bb155dcfd26080051d7dd65823c906b1d0e665876f899e93a08aad44d48d7e1f19aa623f53795f4b030e231eeaa46b5aa31245a81188c3bdc1d0fc25ace5b48ff5c0c9604aee8bf5b3d245e7d12361fdc4537885be6ffabb50ce09683b13810eb2d861ad4e9c369cdf1cdcd12bab1dd1e5c0cfdc02ac7ca46c4d787c2a60af8f60c7f80fcdd7dee1ef6bd43af6240405f8adc8dc70b2bb025bc8b4015efd6bc7f11552d4ce766ed4ed984c2b05d70802b1c7aae81643da0186b45faaea4679fae26b32ef803ad9511de73f506fea694217d974960a6ddc88c9d8983883b20d657ef5e09711913badb3b6cbd70b175ae2b4234b510122079066a30e0c3c7f52280457e09053828a7d8966b778d4fcc651d85d387a0978bf74ce4283e94dc67fe4777b490aa5cba255ae13ba6685098cd5f3a17077e4b67cfb3c2dd0440e1e1bdb52b08c4557c35146e4d1f9429c04429f82d3280d71bec502e2517ea42122f1603bb4ad08b9d558664006360b578b3416d05165e5882381c456b9586c6f187bd7548987e0ca5403ba0095f8004492197b26d40af203935997a690175d2f2e495b01fa59415fdb56a0bd97f27deaf6b8e3b1ce5fb0a99c100d17333a5052f03c70676279b008f91cf13e6efa3fca1305b73014f0449e00ddc6d869813667ee1fd07c06d61f94881be2edca2597aa1abe09569b369136928060caa050814a6b8fb5c7aa4c437ebb2aabe5aeb587d2d1d056297e8a8b0b235373f72208e44be93cb6680d6149f74c007b2e35bc52ffdd893e719788d27b687c6ebd2788a96e2dd548401aa15c0c4a1ef98062e3e32617b8e72d3783bb9dcb484ae5c9f8d25a585ebf111ac9f4ffd3b7b414295de36a77c4e02c732af56474de7e05fddc43692c2a4d36c42049d2add080178eaca2efb7ddae3c20f38e967ee04b5df04f701a44be9edfd96c40e32caf06ce6b6fb4afd4da085a64e362ef95a1528970fe9e6d998e0908de4f25ae0189f23ad1d38a0258cdbf452680432624f574857816153354b6a9cbc9abb5c15a8da0e3751187908281ac4da6803f5788ca950251f6bde5545967e352e6b8a900dee6360d54db408ca7a1a00c45e4f04befd7c96d3d3ee62d2587df10b0af7d331a7516df03b1f91be9b924207e149c9fecf94dad8c64f94e413902c0dc2d644f6

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29

Check failure on line 506 in packages/edge-preview-authenticated-proxy/tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (windows-latest, ./packages/*)

tests/index.test.ts > Raw HTTP preview > should fallback to the request method if the X-CF-Http-Method header is missing

Error: toMatchInlineSnapshot cannot be called multiple times at the same location. ❯ tests/index.test.ts:506:29
});

it("should strip cf-ew-raw- prefix from headers which have it before hitting the user-worker", async () => {
const token = randomBytes(4096).toString("hex");
const resp = await worker.fetch(
Expand Down
25 changes: 25 additions & 0 deletions packages/playground-preview-worker/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,31 @@ describe("Preview Worker", () => {
);
expect(await resp.text()).toMatchInlineSnapshot('"custom"');
});
it("should return method specified on the X-CF-Http-Method header", async () => {
const resp = await fetch(`${PREVIEW_REMOTE}/method`, {
method: "POST",
headers: {
"X-CF-Token": defaultUserToken,
"X-CF-Http-Method": "PUT",
"CF-Raw-HTTP": "true",
},
redirect: "manual",
});

expect(await resp.text()).toMatchInlineSnapshot('"PUT"');
});
it("should fallback to the request method if the X-CF-Http-Method header is missing", async () => {
const resp = await fetch(`${PREVIEW_REMOTE}/method`, {
method: "PUT",
headers: {
"X-CF-Token": defaultUserToken,
"CF-Raw-HTTP": "true",
},
redirect: "manual",
});

expect(await resp.text()).toMatchInlineSnapshot('"PUT"');
});
it("should reject no token for raw HTTP response", async () => {
const resp = await fetch(`${PREVIEW_REMOTE}/header`, {
headers: {
Expand Down

0 comments on commit 184d121

Please sign in to comment.