Endpoint not correctly overridden
kylebarron opened this issue · comments
Kyle Barron commented
I'm following the Parse Server guide trying to set up the file adapter to work with Digital Ocean spaces, which uses an S3-compliant API. I've essentially copy-pasted the guide's example, but it seems like the endpoint override isn't carrying through to the actual file adapter object.
Example code:
require("dotenv").config();
var S3Adapter = require("parse-server").S3Adapter;
var AWS = require("aws-sdk");
var spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
var s3Options = {
bucket: process.env.S3_BUCKET_NAME,
baseUrl: process.env.S3_BASE_URL,
region: process.env.S3_REGION,
directAccess: true,
globalCacheControl: "public, max-age=31536000",
bucketPrefix: process.env.S3_BUCKET_PREFIX,
s3overrides: {
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET_KEY,
endpoint: spacesEndpoint
}
};
var s3AccessKey = process.env.S3_ACCESS_KEY;
var s3SecretKey = process.env.S3_SECRET_KEY;
var s3Bucket = process.env.S3_BUCKET_NAME;
var filesAdapter = new S3Adapter(s3AccessKey, s3SecretKey, s3Bucket, s3Options);
console.log(spacesEndpoint);
console.log(s3Options);
console.log(filesAdapter);
Where the environment variables are:
S3_ACCESS_KEY=
S3_BASE_URL=https://nst-guide-parse.nyc3.digitaloceanspaces.com
S3_BUCKET_NAME=nst-guide-parse
S3_BUCKET_PREFIX=parse-files/
S3_REGION=nyc3
S3_SECRET_KEY=
SPACES_ENDPOINT=nyc3.digitaloceanspaces.com
And output:
Endpoint {
protocol: 'https:',
host: 'nyc3.digitaloceanspaces.com',
port: 443,
hostname: 'nyc3.digitaloceanspaces.com',
pathname: '/',
path: '/',
href: 'https://nyc3.digitaloceanspaces.com/'
}
{
bucket: 'nst-guide-parse',
baseUrl: 'https://nst-guide-parse.nyc3.digitaloceanspaces.com',
region: 'nyc3',
directAccess: true,
globalCacheControl: 'public, max-age=31536000',
bucketPrefix: 'parse-files/',
s3overrides: {
accessKeyId: 'redacted',
secretAccessKey: 'redacted',
endpoint: Endpoint {
protocol: 'https:',
host: 'nyc3.digitaloceanspaces.com',
port: 443,
hostname: 'nyc3.digitaloceanspaces.com',
pathname: '/',
path: '/',
href: 'https://nyc3.digitaloceanspaces.com/'
}
}
}
S3Adapter {
_region: 'nyc3',
_bucket: 'nst-guide-parse',
_bucketPrefix: 'parse-files/',
_directAccess: true,
_baseUrl: 'https://nst-guide-parse.nyc3.digitaloceanspaces.com',
_baseUrlDirect: false,
_signatureVersion: 'v4',
_globalCacheControl: 'public, max-age=31536000',
_encryption: undefined,
_s3Client: Service {
config: Config {
credentials: [Credentials],
credentialProvider: [CredentialProviderChain],
region: 'nyc3',
logger: null,
apiVersions: {},
apiVersion: null,
endpoint: 's3.nyc3.amazonaws.com',
httpOptions: [Object],
maxRetries: undefined,
maxRedirects: 10,
paramValidation: true,
sslEnabled: true,
s3ForcePathStyle: false,
s3BucketEndpoint: false,
s3DisableBodySigning: true,
computeChecksums: true,
convertResponseTypes: true,
correctClockSkew: false,
customUserAgent: null,
dynamoDbCrc32: true,
systemClockOffset: 0,
signatureVersion: 'v4',
signatureCache: true,
retryDelayOptions: {},
useAccelerateEndpoint: false,
clientSideMonitoring: false,
endpointDiscoveryEnabled: false,
endpointCacheSize: 1000,
hostPrefixEnabled: true,
stsRegionalEndpoints: null,
params: [Object],
globalCacheControl: 'public, max-age=31536000',
accessKeyId: 'redacted',
secretAccessKey: 'redacted'
},
isGlobalEndpoint: false,
endpoint: Endpoint {
protocol: 'https:',
host: 's3.nyc3.amazonaws.com',
port: 443,
hostname: 's3.nyc3.amazonaws.com',
pathname: '/',
path: '/',
href: 'https://s3.nyc3.amazonaws.com/'
},
_events: { apiCallAttempt: [Array], apiCall: [Array] },
MONITOR_EVENTS_BUBBLE: [Function: EVENTS_BUBBLE],
CALL_EVENTS_BUBBLE: [Function: CALL_EVENTS_BUBBLE],
_clientId: 1
},
_hasBucket: false
}
You can see that the Endpoint
is pointing to the Digital Ocean spaces URL in s3Options
, but once passed to S3Adapter()
, the values are passed back to pointing to AWS.