-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduced BASE_URL environment variable #288
base: master
Are you sure you want to change the base?
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... |
@@ -29,7 +29,7 @@ const scripts = () => { | |||
return js(filePath, { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.js
style.css
etc. 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_URL
which can essentially be expressed aswhich will rewrite imports of
index.js
to point to/ackee/index.js
instead. Similarly it also repoints/api
requests 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.