Proxy API calls

Whenever a resulting URL looks something like:<nodeId>/attachments/thumb.jpg
It works great as an API URL but not necessarily as one that can be resolved by the end user's browser.  In a typical Node.js-based architecture, you have the 
  • User’s browser
  • Node.js application server
  • Cloud CMS backend API
The URL generated above is the URL directly to the resource in the backend API.   What you really would prefer to have is a /proxy URL that flows through the application server.
Fortunately, we provide this. You might take a look at the cloudcms-server NPM module. There are a few examples of this in the SDK but the basic idea is that you can have your Node.js application bind in controller methods that sit in between the browser and the backend API. One of these controller methods is /proxy which passes everything through to the API and also logs in using guest or read-only privileges. If you use that, the URL for the image could be better represented like this:<nodeId>/attachments/thumb.jpg
Furthermore, the cloudcms-server NPM module gives you controller methods that let you do virtualized asset retrieval. One of these is the /static controller method which would let you represent the URL like this:<nodeId>/thumb.jpg
And it also includes an automatic thumbnail (or preview) generation URL which will generate thumbnails for you on the fly, like this:<nodeId>/thumb?name=default&mimetype=image/jpg&size=64
This would automatically generate a new attachment called "thumb" from the source attachment "default" and perform some mimetype and sizing conversions for you.