Can a platform programmatically get a user's Glitch URL?

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.

The docs actually imply that this can be done:

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?

To give some additional context, here is the Facebook Messenger Glitch quickstart.

Note the language about copying the public URL.

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.

I removed the link to our example project as it’s no longer relevant.

1 Like

It wasn’t removed, it just moved to the share menu.

The project_domain env value lets you use the 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.

But here’s an example of it in use:!/github-oauth

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:

Yet another idea: maybe the URL can only be accessed with embedded Glitch projects, similar to RunKit.

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.

There are two ways to create a project and populate the .env file while remixing right now. You can make a link like this:!/remix/<base-name>?<var1>=<value1>&<var2=value2>

The other way is to POST to a URL like this:<base-name>/remix

In that case, you should send a JSON body with the environment vars like this:

    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.

Thanks, Tim. I created an example project. It returns:

  "joinLink": "!/join/5030acdb-3676-4c32-b662-aea5111aaaaa"

This was the request:

  type: 'POST',
  url: '',
  data: {
    env: {
      env1: 'test',
      env2: 'testing' 
}).done(function(res) {
  console.log('post results', res);    

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.

  type: 'POST',
  url: '',
  data: {
    "env": {
      "env1": 'test',
      "env2": 'testing' 
  // contentType: "application/json; charset=utf-8",  // <--- Creates CORS Error
  dataType: "json"
}).done(function(res) {
  console.log('post results', res);    

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.

so whats the solution to this? i need the base URL. and its no where to be found. please put step by step.

What are you trying to do? You can get the base url from within the project using the project_domain env value.

@Jay1001 If you are building a platform that needs the callback URL after the Glitch project spins up, check out this solution from the 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