Skip to content

Commit

Permalink
add comment about try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Dec 13, 2023
1 parent c8be08b commit e78007b
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ function fixFunctionContentsForLocalhostServerActions(contents: string) {

contents = contents.replace(
'console.warn("Missing `origin` header from a forwarded Server Actions request.");',
// Note: this is a pretty brittle change and we even introduce a new variable named `wranglerPagesDevLocalhostFixApplied`,
// just in case the source code changes making the variable get out of scope, let's add a try catch here so that in
// the worst case scenario if the variable is not recognized the user code still runs fine (and the only broken thing
// would be that the console.warn would not get called)
'try { !wranglerPagesDevLocalhostFixApplied && console.warn("Missing `origin` header from a forwarded Server Actions request."); } catch {}',
);
}
Expand Down

0 comments on commit e78007b

Please sign in to comment.