Skip to content

Commit

Permalink
fix: should use origin url with @marko/run (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Jul 20, 2023
1 parent 67e37fd commit df6e6f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/micro-frame/component/node.marko
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ static async function fetchStream(input, out) {
let incomingHeaders;
if (global.platform) {
const url = global.url;
if (!url) {
throw new Error("Please assign $global.platform.url with WHATWG URL object compatible with @marko/run.");
}
const request = global.request;
if (!request || !request.headers) {
throw new Error("Please assign $global.platform.request with WHATWG request object compatible with @marko/run.");
}
incomingHeaders = Object.fromEntries(request.headers);
origin = request.url;
origin = url.origin;
} else {
const incomingMessage = out.stream && (out.stream.req || out.stream.request) || out.global.req || out.global.request;
if (!incomingMessage) {
Expand Down
8 changes: 7 additions & 1 deletion src/components/stream-source/component/node.marko
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ $ const request = async () => {
let incomingHeaders;
if (global.platform) {
const url = global.url;
if (!url) {
throw new Error("Please assign $global.platform.url with WHATWG URL object compatible with @marko/run.");
}
const request = global.request;
if (!request || !request.headers) {
throw new Error("Please assign $global.platform.request with WHATWG request object compatible with @marko/run.");
}
incomingHeaders = Object.fromEntries(request.headers);
origin = request.url;
origin = url.origin;
} else {
const incomingMessage = out.stream && (out.stream.req || out.stream.request) || out.global.req || out.global.request;
if (!incomingMessage) {
Expand Down

0 comments on commit df6e6f1

Please sign in to comment.