Overview
This is a memo on building a proxy server for mdx I’s object storage.
Background
The mdx I user guide explains the following.
https://docs.mdx.jp/ja/index.html#オブジェクトストレージ
This is a DataDirect Networks manual describing the API specifications handled by the S3 Data Service (DDN EXAScaler S3 Data Service) provided by mdx. Please review it together with the object storage usage examples in Tips.
I loaded this into Google NotebookLM and checked the CORS implementation status. The following is the answer.
Answer
Since the documentation clearly states that the Bucket CORS Feature is not implemented, when JavaScript running in a web browser makes a request directly to the EXAScaler Access S3 API from a different origin (e.g., JavaScript provided by a website on a different domain than the API endpoint), CORS (Cross-Origin Resource Sharing) issues will occur and requests will typically be blocked.
This is due to the web browser’s Same-Origin Policy security mechanism. Access to resources from different origins is restricted unless explicitly allowed by the server. CORS provides this permission mechanism, but since this feature has not yet been implemented in EXAScaler Access S3, there will be no CORS headers in server responses, and the browser will reject cross-origin requests.
Therefore, a workaround such as using a proxy server may be necessary, where client-side requests are first sent to the proxy server, which then makes requests to the EXAScaler Access S3 API, making the origins appear to match. The proxy server can also add necessary headers to API responses.
However, this is just one common method to work around CORS issues, and there are other methods such as matching origins when exposing APIs on the server side. The important point is that since the EXAScaler Access S3 API itself does not support the CORS mechanism, some countermeasure is needed when making cross-origin requests directly from the client side.
Solution
While my understanding may be incorrect in some areas, based on the above answer, I decided to build a proxy server for mdx I’s object storage.
The repository for the proxy server I built is below.
https://github.com/nakamura196/s3-proxy
For example, you can access files on the specified bucket at the following URL.
https://s3-proxy.vercel.app/public/CETEIcean.css
In contrast, the following is an example of direct access.
https://s3ds.mdx.jp/satoru196/public/CETEIcean.css
For the former, you can confirm response headers like the following, verifying that CORS is configured.
Implementation
I implemented it using Express as follows. Note that aws-sdk needs to be migrated to AWS SDK for JavaScript v3.
Summary
My understanding may be incorrect in some areas, but I hope you find this helpful.