diff options
| author | 2022-01-01 18:12:57 -0800 | |
|---|---|---|
| committer | 2022-01-01 18:12:57 -0800 | |
| commit | 6a28cfd2ba7484df34d07054cd29fe4cfbce7f53 (patch) | |
| tree | 4156ec993fd47674b9674f927c5f6b4c8b487b6a /src/css_scanner.zig | |
| parent | e4693b8aaf658b16b901f655ea70ee5e4a1a988c (diff) | |
| download | bun-6a28cfd2ba7484df34d07054cd29fe4cfbce7f53.tar.gz bun-6a28cfd2ba7484df34d07054cd29fe4cfbce7f53.tar.zst bun-6a28cfd2ba7484df34d07054cd29fe4cfbce7f53.zip | |
[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.
Diffstat (limited to 'src/css_scanner.zig')
| -rw-r--r-- | src/css_scanner.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/css_scanner.zig b/src/css_scanner.zig index 10f065058..55b3298d2 100644 --- a/src/css_scanner.zig +++ b/src/css_scanner.zig @@ -19,7 +19,7 @@ const logger = @import("./logger.zig"); const Options = options; const resolver = @import("./resolver/resolver.zig"); const _linker = @import("./linker.zig"); - +const URL = @import("./query_string_map.zig").URL; const replacementCharacter: CodePoint = 0xFFFD; pub const Chunk = struct { @@ -1020,6 +1020,7 @@ pub fn NewWriter( import.text.utf8, chunk.range, import_record.ImportKind.at, + writer.buildCtx.origin, Options.BundleOptions.ImportPathFormat.absolute_path, true, ) catch |err| { @@ -1066,6 +1067,7 @@ pub fn NewWriter( url.utf8, chunk.range, import_record.ImportKind.url, + writer.buildCtx.origin, import_path_format, true, ); @@ -1078,6 +1080,7 @@ pub fn NewWriter( import.text.utf8, chunk.range, import_record.ImportKind.at, + writer.buildCtx.origin, import_path_format, false, ); @@ -1155,6 +1158,8 @@ pub fn NewBundler( fs_reader: FileReader, fs: FSType, allocator: std.mem.Allocator, + origin: URL = URL{}, + pub fn bundle( absolute_path: string, fs: FSType, @@ -1166,6 +1171,7 @@ pub fn NewBundler( allocator: std.mem.Allocator, log: *logger.Log, linker: Linker, + origin: URL, ) !CodeCount { if (!has_set_global_queue) { global_queued = QueuedList.init(default_allocator); @@ -1186,7 +1192,7 @@ pub fn NewBundler( .writer = writer, .fs_reader = fs_reader, .fs = fs, - + .origin = origin, .allocator = allocator, .watcher = watcher, }; |
