Skip to content

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

@sgatkal

Description

@sgatkal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions