box / box/box-content-preview

Preview.js CDN includes box API version 2.0 appends to API_HOST

Open
#1,480 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
120
Forks
137
Avg merge
12h 36m
Merged PRs (30d)
17

Description

Environment: JS

Preview version: 2.93.0 (latest)
Steps to reproduce the problem:

1. After adding API_HOST in use a reverse proxy and instead of using api.box.com use a custom domain.
Below is example of code.
var oB=document.getElementById('preview');
var addExtraHeaders = (config /* https://github.com/axios/axios#request-config */) => {
config.headers['ApplicationId'] = '12345';
return config;
};
oB.onload=function(){
var accessToken = 'ygasdfygasldlkfnjasdf';
var fileId = 5454151;
var preview = new Box.Preview();
preview.show(
fileId,
accessToken,
{
apiHost: "https://mydocuments.getme.com/",
requestInterceptor: addExtraHeaders,
container: "#my-doc", showDownload:true,
logoUrl:'.\images\myorg.png'
}
);

2. Once call made from Preview.js CDN it appends /2.0/ to original API_HOST.
3. Additional 2.0 makes it difficult to customize API call while using Preview.js CDN library.

What is the expected behavior? (Screenshots can be helpful here)
the expected behavior is when we pass Custom API host it should not append any version to request API. This call should be agnostic to BOX API version and should call files [https://api.box.com/2.0/files/12345].
May be version [2.0] should be an options to provide along with API_HOST url.

What went wrong? (Screenshots, console logs, or HAR files can be helpful here)
Customization with API_HOST URL not working due to version got appended to request. This creates dependencies on BOX API version and custom API.
Is it possible that instead of appending 2.0 to API host create options to pass version along with API_HOST or use https://api.box.com/2.0/ as a default BOX_API URL in CDN.

Contributor guide

Open the contributing guide

Research direction

Start with the CDN Preview.js entry point and the apiHost configuration shown in the reproduction. Trace where requests add /2.0/ to a custom host, then verify that a custom API host can remain version-agnostic while the default Box API URL still reaches the expected files endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.