You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bellow is a simple proxy server that receives requests from AWS SDK V3 Clients and an example using aws-sdk-v3-proxy configured to work with the proxy server.
// example.ts
import{S3Client,ListBucketsCommand}from"@aws-sdk/client-s3";import{addProxyToClient}from'aws-sdk-v3-proxy';console.log(`HTTP_PROXY: ${process.env.HTTP_PROXY}`);console.log(`HTTPS_PROXY: ${process.env.HTTPS_PROXY}`);consts3=addProxyToClient(newS3Client({region: "us-east-2",}));s3.middlewareStack.add((next,context)=>async(args: any)=>{args.request.headers["x-my-account-id"]="9b8c209d-73c9-4d97-9923-e256de630f39";console.log(args);constresult=awaitnext(args);// result.response contains data returned from next middleware.returnresult;},{step: "build",});(asyncfunctionmain(){try{constresponse=awaits3.send(newListBucketsCommand());console.log(response);}catch(err){console.log(err);}})();
//proxy.ts
importexpress,{Request,Response}from'express';constapp=express();constport=3000;app.use(express.json());app.all('*',async(req: Request,res: Response)=>{try{console.log(req);constaccountId=req.headers["x-my-account-id"];console.log(accountId);res.status(200).json({message: "works"});}catch(error){console.error("unknown error");res.status(500).json({error: "unknown error"});}});app.listen(port,()=>{console.log(`Proxy server listening at http://localhost:${port}`);});
I believe that the sdk client is trying to send the request through the proxy but the proxy isn't accepting and there is no clue why! I also tried with fastify and had no lucky. I need help
I also console.log req.originalUrl and req.haders and discovered they were changed. Why? I just want to forward the request. My plan is to add some credentials to it before forwarding the request to AWS.
//proxy.ts
importexpress,{Request,Response}from'express';constapp=express();constport=3000;app.use(express.json());app.all('*',async(req: Request,res: Response)=>{try{console.log('Original URL:',req.originalUrl);console.log('Headers:',req.headers);res.status(200).json({});}catch(error){console.error("unknown error");res.status(500).json({error: "unknown error"});}});app.listen(port,()=>{console.log(`Proxy server listening at http://localhost:${port}`);});
Current Behavior
Bellow is a simple proxy server that receives requests from AWS SDK V3 Clients and an example using aws-sdk-v3-proxy configured to work with the proxy server.
// example.ts
//proxy.ts
Expected Behavior
Steps to Reproduce the Problem
I believe that the sdk client is trying to send the request through the proxy but the proxy isn't accepting and there is no clue why! I also tried with fastify and had no lucky. I need help
Environment
"aws-sdk-v3-proxy": "^2.1.4"
,The text was updated successfully, but these errors were encountered: