Skip to content

Commit

Permalink
Merge pull request #25 from movie-web/dev
Browse files Browse the repository at this point in the history
Proxy v2.1.2
  • Loading branch information
binaryoverload authored Jan 6, 2024
2 parents e216a59 + 02b4dca commit 7dc9d18
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions nitro.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { join } from "path";
import pkg from "./package.json";

//https://nitro.unjs.io/config
export default defineNitroConfig({
noPublicDir: true,
srcDir: "./src",
runtimeConfig: {
version: pkg.version
},
alias: {
"@": join(__dirname, "src")
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-proxy",
"private": true,
"version": "2.1.1",
"version": "2.1.2",
"scripts": {
"prepare": "nitropack prepare",
"dev": "nitropack dev",
Expand Down
4 changes: 3 additions & 1 deletion src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default defineEventHandler(async (event) => {
event,
status: 200,
data: {
message: 'Proxy is working as expected',
message: `Proxy is working as expected (v${
useRuntimeConfig(event).version
})`,
},
});

Expand Down
3 changes: 3 additions & 0 deletions src/utils/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const blacklistedHeaders = [
'cf-ray',
'cf-visitor',
'cf-ew-via',
'cdn-loop',
'x-amzn-trace-id',
'cf-ipcountry',
'x-forwarded-for',
'x-forwarded-host',
'x-forwarded-proto',
Expand Down
10 changes: 9 additions & 1 deletion src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export async function specificProxyRequest(
opts.fetchOptions?.headers,
opts.headers,
);
(fetchHeaders.forEach as any)(console.log);
const headerObj = Object.fromEntries([...(fetchHeaders.entries as any)()]);
if (process.env.REQ_DEBUG === 'true') {
console.log({
type: 'request',
method,
url: target,
headers: headerObj,
});
}

return sendProxy(event, target, {
...opts,
Expand Down

0 comments on commit 7dc9d18

Please sign in to comment.