nteract / commuter

🚎 Notebook sharing hub
BSD 3-Clause "New" or "Revised" License
495 stars 66 forks source link

add an option to enable s3ForcePathStyle #285

Closed sasan-j closed 4 years ago

sasan-j commented 4 years ago

Hi,

I was trying to configure Commuter with the S3 compatible object storage MinIO however I would get the following error:

[Error [AjaxError]: ajax error 500] {
  xhr: {
    UNSENT: 0,
    OPENED: 1,
    HEADERS_RECEIVED: 2,
    LOADING: 3,
    DONE: 4,
    readyState: 4,
    onreadystatechange: [Function: xhrReadyStateChange] {
      subscriber: [AjaxSubscriber],
      progressSubscriber: undefined,
      request: [Object]
    },
    responseText: '{"message":"getaddrinfo ENOTFOUND <MY_BUCKET_NAME_REDACTED>.<MY_ENDPOINT_REDACTED>: ","reason":"NetworkingError"}',
    responseXML: '',
    status: 500,
    statusText: null,
    withCredentials: false,
    open: [Function (anonymous)],
    setDisableHeaderCheck: [Function (anonymous)],
    setRequestHeader: [Function (anonymous)],
    getResponseHeader: [Function (anonymous)],
    getAllResponseHeaders: [Function (anonymous)],
    getRequestHeader: [Function (anonymous)],
    send: [Function (anonymous)],
    handleError: [Function (anonymous)],
    abort: [Function (anonymous)],
    addEventListener: [Function (anonymous)],
    removeEventListener: [Function (anonymous)],
    dispatchEvent: [Function (anonymous)],
    ontimeout: [Function: xhrTimeout] {
      request: [Object],
      subscriber: [AjaxSubscriber],
      progressSubscriber: undefined
    },
    onload: [Function: xhrLoad] {
      subscriber: [AjaxSubscriber],
      progressSubscriber: undefined,
      request: [Object]
    },
    timeout: 0,
    responseType: 'json'
  },
  request: {
    async: true,
    createXHR: [Function: createXHR],
    crossDomain: true,
    withCredentials: false,
    headers: {},
    method: 'GET',
    responseType: 'json',
    timeout: 0,
    url: 'http://127.0.0.1:4000/api/contents//',
    body: undefined
  },
  status: 500,
  responseType: 'json',
  response: {
    message: 'getaddrinfo ENOTFOUND <MY_BUCKET_NAME_REDACTED>.<MY_ENDPOINT_REDACTED>: ',
    reason: 'NetworkingError'
  }
}

This is using version 5.9.1. I noticed from the MinIO's guide to use aws-sdk that the configuration should be something like this (source):

var s3  = new AWS.S3({
          accessKeyId: 'YOUR-ACCESSKEYID' ,
          secretAccessKey: 'YOUR-SECRETACCESSKEY' ,
          endpoint: 'http://127.0.0.1:9000' ,
          s3ForcePathStyle: true, // needed with minio
          signatureVersion: 'v4'
});

So what I did was adding the s3ForcePathStyle: true and it works nicely with MinIO. How about we add an environmental variable called COMMUTER_S3_FORCE_PATH_STYLE or something like that so by setting it commuter can be used with MinIO and I suspect other tools or use-cases this option is needed? I went ahead and created a PR. Any thoughts?

p.s. I'm not quite familiar with javascript coding conventions

captainsafia commented 4 years ago

Merging now. Thanks!

captainsafia commented 4 years ago

Just published v5.10.0 with this change.