mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
[bun dev] Automatically set origin - improve support for proxying Bun
Previously, when running Bun behind a reverse proxy, you had to pass an explicit `--origin` arg and it could only run behind one proxy at a time. Now, Bun automatically determines the origin from the request if possible. It reads `Forwarded`, `X-Forwarded-Proto`, `X-Forwarded-Host`, `Origin`, and lastly `Host`. If none are available, it falls back to the `--origin` CLI arg. This change is important for usecases like Replit which shows multiple iframes in different origins.
This commit is contained in:
@@ -390,11 +390,12 @@ pub fn getScriptSrcString(
|
||||
&entry_point_tempbuf,
|
||||
Fs.PathName.init(file_path),
|
||||
),
|
||||
VirtualMachine.vm.origin,
|
||||
ScriptSrcStream.Writer,
|
||||
writer,
|
||||
);
|
||||
} else {
|
||||
JavaScript.Bun.getPublicPath(file_path, ScriptSrcStream.Writer, writer);
|
||||
JavaScript.Bun.getPublicPath(file_path, VirtualMachine.vm.origin, ScriptSrcStream.Writer, writer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user