Introduced BASE_URL environment variable#288
Introduced BASE_URL environment variable#288nergmada wants to merge 8 commits intoelecterious:masterfrom
Conversation
|
Someone is attempting to deploy a commit to a Personal Account owned by @electerious on Vercel. @electerious first needs to authorize it. |
|
Hello @nergmada , thanks for your additions... I will wait for your confirmation to proceed with testing. |
|
@bacloud14 so DO's App Platform is like an series of microservices all built on one domain but on different endpoints. Not to get into the finer points of what I did but essentially we have lots of small node instances running on a domain such as www.example.com
Each of these is an individual "server" running it's own node instance. It's kind of like kubernetes, but it's more online and gui based config. If you can clarify your question a bit more about how you'd want to run it as a single a service? Off the top of my head if you're running say an express server, on a single machine. I'd put your express server on say port 2000, your Ackee server on say port 3000 and then if you want express to forward all requests for /analytics on to Ackee do something like app.use('/analytics/*', functionToForwardReqToLocalhost3000) Note that your function would need to rewrite the request path to work with my code e.g. /analytics/api/getViews would need to be rewritten as /api/getViews, not that it would be very hard. Then set BASE_URL in Ackee to www.yourdomain.com/analytics or whatever path you sent for "/analytics/*" -Adam |
|
I thought it would be possible for Ackee somehow to be a middleware inside an existing app. Without http messaging between the app being monitored and Ackee. That would probably ease the process of integration. Check this simple middleware for instance. Good luck |
|
Another example for analytics is express-keenio but they offer the service (DB and dashboard I imagine) on the cloud, so... |
| optimize: config.isDevelopmentMode === false, | ||
| nodeGlobals: config.isDevelopmentMode === true, | ||
| replace: { 'process.env.NODE_ENV': JSON.stringify(config.isDevelopmentMode === true ? 'development' : 'production') }, | ||
| replace: { 'process.env.NODE_ENV': JSON.stringify(config.isDevelopmentMode === true ? 'development' : 'production'), 'process.env.BASE_URL': config.baseUrl }, |
There was a problem hiding this comment.
You can move this up to the index function. The last argument of the layout function accepts environment variables that you can access via window.env in the UI scripts.
Hi,
I've been doing some looking for Open Source privacy-first analytics services for a client project I am working on. I love the look of Ackee and in order to integrate it I've had to modify it a little.
Because our service runs on DigitalOcean's App Platform, we deploy in using a node droplet rather and a docker droplet. This is mostly to do with a desire to avoid using a reverse proxy. However, we encountered an issue when deploying on a URL other than root e.g.
www.mydomain.com/ackee
Ackee will deploy fine on www.mydomain.com however, because the HTML is hard coded to import
index.jsstyle.cssetc. if these files are being served on a route other than the index route, the system falls over. More than that, I wasn't really in the mood to deploy an Nginx instance to wrap around this for the sake of rewriting the retrieval of 3 files.For this reason, I've introduced a new environment variable
BASE_URLwhich can essentially be expressed aswhich will rewrite imports of
index.jsto point to/ackee/index.jsinstead. Similarly it also repoints/apirequests to/ackee/api.This change does not modify the serverless functions notion of it's route (e.g. src/server.js:96), on the basis that DO masks incoming requests e.g.
if I make a request to www.mydomain.com/ackee/api/getViews (I realise this isn't necessarily an actual endpoint, I'm just demonstrating), Ackee will get
/api/getViews.Depending on demand and use cases, it may be appropriate to introduce a SERVER_BASE_URL variable which similarly prepends the serverless instance's notion of its URL.