It looks like the public url link / copy button was recently taken out of the project menu.
Unfortunately this makes a previously painful problem now a bit more painful:
After sending a user to Glitch with the Button API, how how can I programatically get the URL of their newly created project?
This “copy public URL” link was my best workaround for onboarding users.
Why need this?
In an OAuth2 handshake, the platform that issues the keys needs to know the URL authorizing app. Same with an application that processes webhooks. The public URL is a necessary config value for many platform scenarios.
I made another suggestion to let the developer pass a random subdomain as part of the environment.
PROJECT_DOMAIN – Contains your project’s name, useful for programmatically specifying your project’s URL
However, passing PROJECT_DOMAIN in the button API does not set the subdomain. The “copy public URL” field was an ok workaround.
If Glitch is being used to extend other products there must be a programmatic way to hand off the the public URL of the project. Making one-click setups for platforms would be so much more awesome.
Does anyone happen to have a workaround?
EDIT:
To give some additional context, here is the Facebook Messenger Glitch quickstart.
But imagine if there was just a single “Remix In Glitch” button that passed the client id, client secret, and subdomain. It would be a one-click FB Messenger app. No setup required.
EDIT:
I removed the link to our example project as it’s no longer relevant.
It wasn’t removed, it just moved to the share menu.
The project_domain env value lets you use the Glitch.me sub-domain for an app in the app’s code without having to know it, rather than set your own value for it. I’ll rephrase this in the docs so it’s clearer.
Allowing a third-party to specify a project name is problematic in scenarios where it’s already taken etc. Perhaps getting a return value with the new project’s name might be useful?
Thanks, Gareth. Makes sense about subdomain name collisions.
Perhaps getting a return value with the new project’s name might be useful?
Yes, any method of returning that programmatically would be great.
For now, we continually running a callback function within the first ~10 minutes of the life of the Glitch project that posts a token (as a lookup key) and the projects’s public URL to an endpoint on our end. So, we have our on-click Glitch link after all.
Another idea: maybe an eventual Glitch API could expose the renaming functionality shown in the UI:
Glitch is already so awesome, and our needs are solved for now. Just throwing ideas out there from the perspective of a platform trying to optimize Glitch onboarding for our developers. Hope it helps.
In that case, you should send a JSON body with the environment vars like this:
{
env:
var1: "value1"
var2: "value2"
}
The POST endpoint returns the join link for the project right now. We might be able to change that to return a JSON object that also includes the domain. Off the top of my head, I don’t remember how many things are using the returned data.
If this also returned the project domain it would be perfect for our use-case. It also sounds like the cleanest of the implementation ideas above.
Our “One Click Glitch” setup would made be far less complicated.
Edit: My code as above returned the “join” link as expected, but when adding contentType: "application/json; charset=utf-8" I started getting a CORS error.
It may be on my end. I don’t have time to debug, but wanted to the latest progress.
Also, I noticed the Glitch Project does not actually initialize until I visit the join URL. If this method was implemented, it would be ideal to let the developer pass a flag or something to initialize immediately.
@Jay1001 If you are building a platform that needs the callback URL after the Glitch project spins up, check out this solution from the Howdy.ai guys. I ended up doing something similar.
The registerDeployWithStudio function basically just posts the project_domain env value back to to your platform along with some identifying / auth information so it can be properly saved.
If you just need the base url, then it’s just process.env.PROJECT_DOMAIN