Has anyone found a reliable way to stop `N/https` ...
# ask-stanley-ai
a
Has anyone found a reliable way to stop
N/https
from forwarding the original
Authorization
header during a 302 redirect? The Problem: > I’m calling a third-party endpoint that redirects to a signed S3 URL. The destination (S3) returns a 400 'InvalidArgument' because NetSuite persists the original Bearer token to the redirected domain, and S3 doesn't allow two auth mechanisms (the header + the query params). The Weird Part: > This works perfectly in standard
fetch
or Postman (as they strip headers cross-domain on redirects), but I need this to run natively in a Suitelet. the external api suggested me to use the "Double-Fetch" workaround (letting it fail to capture the redirected URL), but when S3 returns that 400 error,
response.url
comes back empty/undefined
, leaving me with no URL to re-call. const getDocument = (accessToken, recordId) => { // This call triggers a 302 redirect to a signed storage URL const response = https.get({ url:
<https://api.externalvendor.com/v1/files/${recordId}>
, headers: { 'Authorization': 'Bearer ' + accessToken, 'Accept': 'application/pdf' } });
c
AI generated answer (using internal Slack threads):
Based on the provided Slack threads, it appears that there is no reliable way to stop
N/https
from forwarding the original
Authorization
header during a 302 redirect in NetSuite. The
N/https
module in SuiteScript automatically follows redirects, and there is no control over this behavior. The issue you're facing is due to the fact that NetSuite persists the original Bearer token to the redirected domain, and S3 doesn't allow two auth mechanisms (the header + the query params). Unfortunately, the "Double-Fetch" workaround suggested by the external API doesn't seem to work in this case, as when S3 returns a 400 error,
response.url
comes back empty/undefined, leaving you with no URL to re-call. It's worth noting that this behavior is different from standard
fetch
or Postman, which strip headers cross-domain on redirects. However, since you need this to run natively in a Suitelet, these alternatives may not be applicable. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83038342
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822815061
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818969846
Please provide your feedback on this answer.