# Setup Local Testing

**URL:** <https://discuss.dev.twitch.com/t/setup-local-testing/34302>\
**Category:** Extensions\
**Created:** [October 25, 2021, 7:41pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302 "2021-10-25T19:41:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 7:41pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/1 "2021-10-25T19:41:57Z")

</div>

After I found out that the rig is completely useless for testing because most of the things I try to do aren’t working, I decided to test without the rig. But in the documentation I didn’t find anything how to test without the rig. I know that I have to setup a server which hosts my files but what then? How can I test it afterwards? In the rig i could create views to check how everything is working but how do I do it without the rig?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 7:45pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/2 "2021-10-25T19:45:04Z")

</div>

You install the extension to a channel  
And view it on twitch instead of in the rig.

The rig will spin up a server to hosts files for you.  
But you can use a server with the rig anywau.

Hosting an extension is _technically_ identical to hosting a website.  
Since an extension _is_ jsut a website.

The only thing you need to test on Twitch instead of in the rig, is you need some real SSL certs to prevent mixed content issues.

So to view an extension on Twitch just install and activate it to slot, just like you would a released extension.  
And to view a vidoe extension (either overlay or component) the target channel needs to be live.

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 7:49pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/3 "2021-10-25T19:49:02Z")

</div>

Ok thanks. How do I get a SSL certificate for testing and where do I need to put it?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 7:50pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/4 "2021-10-25T19:50:35Z")

</div>

There are a few ways to get a SSL cert for testing.

These work for a “real domain name”

- Buy one
- get one with your hosting
- get one from Lets Encrypt or other free cert provide

> [@feedo](#):
>
> where do I need to put it?

Depends on how you are hosting. What server type you are using/etc  
Follow those instructions

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 7:52pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/5 "2021-10-25T19:52:49Z")

</div>

Ok I know let’s encrypt, I have setup a simple http server with node npm install -g http-server like in the extension tutorial.

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 8:18pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/6 "2021-10-25T20:18:53Z")

</div>

Ok now I don’t know how to get the certificate from certbot, it’s a while ago since I last used it. There are options on the website to choose which server and what system, what do I need to input there? I don’t know what kind of server the node http-server is opening.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 8:21pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/7 "2021-10-25T20:21:56Z")

</div>

Personally I don’t put my certs into node.

I setup my test environment to more closely match Twitch.  
So I SSL terminate my front end test (and EBS) with nginx and proxy pass to node.  
Then node doesn’t have to faff about with certs.

Also you don’t have to use node to serve your files.

I wrote about my methods on part 5 of my extension blog series [Twitch Extensions Part 5 – Dev Environment – Barry Carlyon](https://barrycarlyon.co.uk/wordpress/2021/03/15/twitch-extensions-part-5/)

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 8:31pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/8 "2021-10-25T20:31:10Z")

</div>

Yeah but what you writing in your Tutorial is a bit over the needs of my simple project.  
It’s so dumb that I need all that knowledge of how to setting up servers and getting SSL certs and in the documentation they say all you need is knowledge of css, html and JavaScript.  
That is simply not true, if I need to test my extension, which everyone needs to, I do need exactly that kind of server knowledge because so many things aren’t working when using the rig.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 8:40pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/9 "2021-10-25T20:40:29Z")

</div>

> [@feedo](#):
>
> That is simply not true, if I need to test my extension, which everyone needs to, I do need exactly that kind of server knowledge because so many things aren’t working when using the rig.

You can upload your files to hosted test and test that way instead. Granted to make a change your have to go back to local test and then reupload a new zip, which is what you would do if you were uploading to a “real” website host.

The bare minimum is HTML/JS/CSS.

Knowing something about servers is useful so you can improve your test environemnt and/or provide an EBS.

EBS being a backend API that your extension might need and that will need SSL too, which might be handled by a hosting provider.

You can host your extension for testing on a “real website” just like a real website and then you are just uploading files to a shared host/whatever hosting, just like a real website.

So yes the minimum you need to know is HTML, JS and css. As an extension works just like a “real website” as essentially it is just just a website.

So you can upload your extension to a “regular” website host and use that URL in your testing base URI.

One of my test extensions even uses GitHub pages to run the hosting. So GitHub handles the hosting and SSL for me, for example.

So you have options on how to deplay you extension/website/files for testing with.  
You don’t need any server knowledge if you are using a hosting provider.

Edit: and as noted in my blog post, you can use ngrok to SSL termiante and tunnel to your node http-server and then ngrok handles SSL and making your extension “world accessble” if you need to test with other people (prior to hosted testing)

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 9:06pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/10 "2021-10-25T21:06:39Z")

</div>

Because of the configuration service which allows me to store simple data, I thought I didn’t need an EBS. If I switch to hosted test, can I simply reupload my packaged zip file if I need to change something?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 9:07pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/11 "2021-10-25T21:07:53Z")

</div>

> [@feedo](#):
>
> Because of the configuration service which allows me to store simple data, I thought I didn’t need an EBS.

That is one use of the config service yes.  
Since it can be set by a broadcaster JWT via the JS helper.

> [@feedo](#):
>
> If I switch to hosted test, can I simply reupload my packaged zip file if I need to change something?

Yes.

You can move from hosted ttest to local test back and forth as much as you want.

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 9:11pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/12 "2021-10-25T21:11:22Z")

</div>

Can I also write data to the configuration service if a viewer performs some action?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 9:13pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/13 "2021-10-25T21:13:46Z")

</div>

Yes and no.

The viewers JWT doesn’t have write access.

But you could in theory recieve the viewers action _somehow_ in an open broadcasters view.  
And then write to the config service.

This isn’t ideal and a EBS would be preferential.

There are a lot of security implications here, hence the viewers JWT cannot write to the config service.

Without a server it’s a clusterfuck to do it and involves too much over head from the broadcaster.

If you have an EBS or some sort of backend service then you can do what you need to do securely.

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 9:25pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/14 "2021-10-25T21:25:13Z")

</div>

Let’s say a viewer is spending bits, is it possible to somehow send a message to the broadcaster through pubsub with the information who was spending and how much?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 9:30pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/15 "2021-10-25T21:30:30Z")

</div>

A users JWT cannot broadcast to extension pubsub.

However if the product is set to “broadcast”  
Then it’s broadcast to all instances of the extension regardless of the person that initiated the transaction.  
So _if_ the broadcaster has a view open then yes the broadcaster could recieve it.

However optimally you’d be using a server to handle this sort of flow. to account for the broadcaster “oh I forgot to open a window” and audit loggin

See `onTransactionComplete ` under [Reference | Twitch Developers](https://dev.twitch.tv/docs/extensions/reference#helper-bits) with `initiator` and more specifically [Monetization | Twitch Developers](https://dev.twitch.tv/docs/extensions/monetization#managing-the-bits-product-catalog)

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 9:37pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/16 "2021-10-25T21:37:14Z")

</div>

Oh man that’s bad, all I need is a simple Json file and some logic to read and write to/from it. Seems that I really need some kind of EBS to serve my needs. I was hoping that I could overcome this issue with the configuration service.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 25, 2021, 9:38pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/17 "2021-10-25T21:38:50Z")

</div>

You could but it would be too error pronoe

Additionally each segment is limited to 5kb so you might run out of space  
It’s also not designed to be written to frequently

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 25, 2021, 9:42pm UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/18 "2021-10-25T21:42:45Z")

</div>

Ok so the configuration service is really not the right for my use case. Thanks again for your help. They should really pay you for your effort if they aren’t already.

---

<div class="post-metadata">

**Author:** ![feedo](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@feedo](https://discuss.dev.twitch.com/u/feedo)\
**Post date:** [October 28, 2021, 1:10am UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/19 "2021-10-28T01:10:36Z")

</div>

In your tutorial part 5, you’ve wrote about reversing a ssh tunnel to handle SSL termination. Can you explain the steps a bit more?  
I understand how to setup a nodejs server to serve my frontend but I don’t know exactly how to proceed afterwards.  
Can I input the ssh command in the cmd? I’m using Windows.  
And how can I get the certificate from Let’s Encrypt and where do I need to put it?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 28, 2021, 1:16am UTC](https://discuss.dev.twitch.com/t/setup-local-testing/34302/20 "2021-10-28T01:16:20Z")

</div>

> [@feedo](#):
>
> And how can I get the certificate from Let’s Encrypt and where do I need to put it?

Refer to the installation instructions for Lets Encrypt as needed for your system.  
And for install refer to the specific instructions for your HTTP server.

> [@feedo](#):
>
> Can I input the ssh command in the cmd? I’m using Windows.

Sure CMD should be able to do it.  
Persoanlly if I was on windows I’d do it in putty.

> [@feedo](#):
>
> In your tutorial part 5, you’ve wrote about reversing a ssh tunnel to handle SSL termination. Can you explain the steps a bit more?

I use NGINX.

For Node behind NGINX you would have NGINX and the node thing on the same server.  
And configure NGINX ot proxy pass a given domain or path to the port the node thing is running on.

In this case NGINX proxy passes to a port.  
Then I SSH in from local, defining a reverse SSH tunnel to that port.  
And the node thing runs locally on a port.

So

Nginx Proxy pass to port  
Local SSH sets up a tunnel between `localport:127.0.0.1:port nginx is proxy passing to`

So in the example in part 5 of the blog

Nginx is proxy passing to `127.0.0.1:8050`  
There is no node thing on that server listening to 8050

So on my local maching. I would usually setup the node thing to listen on 8050  
And then i run

`ssh -R 8050:127.0.0.1:8050 username@example.com`

Which tne setups up `127.0.0.1:8050` to be routed over the SSH tunnel to `127.0.0.1:8050` on the local machine.

This is _basically_ what NGROK does for you in a single command on a random URL.

[Next page](https://discuss.dev.twitch.com/t/setup-local-testing/34302.md?page=2)
