ColdBox - Serve HTML and REST API

I am unsure if what I am trying to do is possible.

I have an app written in Vue 2 with Nuxt that accesses API endpoints run using Coldbox. In dev, the setup has worked fine, but now I need to deploy the front end and back end to a server, and, well, I am stumped.

Is it possible to configure Cold Box to work with static HTML files while simultaneously handling the API requests? I am used to Framework/1, where you could tell the framework to ignore requests to certain folders. Does ColdBox have similar functionality?

Generally speaking, ColdBox, FW/1, or a legacy CF app doesn’t care if there happens to be static files on the server. Those are going ot be served up by the web server without involving CF at all.

site.com/path/to/file.html

will be served directly by the web server, whereas

site.com/path/to/index.cfm

will be sent to CF/Lucee for processing (regardless of whether it’s a framework or not).
And if you’re using rewrites, a URL like

site.com/main/index

gets rewritten by the web server to

site.com/index.cfm/main/index

which still goes to CF/Lucee regardless.

Can you provide details of some actual URLs which are or aren’t getting processed by CF.

I’ve never heard of this-- can you elaborate? Once a request has been passed from the web server to CF/Lucee, it’s past the point in time where the web server can serve it up as a static file. My best guess would be you worked with an app that simply had some conditions for which URLs the framework rewrite happened on, which is really just a feature of URL rewriting, and not specific to any CF framework.

OK…a few things…

First, I am an idiot. I updated my server config to `index.html’ as a ‘welcomeFile’…but, I never restarted the server. It is working now. Serving the static files and the API as seemlessly as I was hoping for.

As for the FW/1 setting, there is a config setting named: `unhandledPaths’ that tells FW/1 not to handle requests to the directories listed.

Awesome!

What happens when you hit one of those paths then? If CF just processes that path as a legacy page, then you could approximate the same behavior by wrapping an if statement around your processColdBox() method in your Application.cfc’s onRequestStart() method, which would just bypass ColdBox. I have a demo of doing this to integrate legacy apps into ColdBox here: