# Angular: use RegEx in a proxy

**URL:** <https://forum.freecodecamp.org/t/angular-use-regex-in-a-proxy/439957>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [January 11, 2021, 9:23am UTC](https://forum.freecodecamp.org/t/angular-use-regex-in-a-proxy/439957 "2021-01-11T09:23:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ultraman64](https://avatars.discourse-cdn.com/v4/letter/u/ee7513/32.png) [@Ultraman64](https://forum.freecodecamp.org/u/Ultraman64)\
**Post date:** [January 11, 2021, 9:23am UTC](https://forum.freecodecamp.org/t/angular-use-regex-in-a-proxy/439957/1 "2021-01-11T09:23:08Z")

</div>

In my Angular app, I have a proxy so I can bypass CORS issues with youtube videos.

This is my proxy:

```auto
{
    "\/api": {
      "target": "https://r1---sn-25ge7nsl.googlevideo.com",
      "secure": true,
      "changeOrigin": true,
      "logLevel": "debug",
      "pathRewrite": {
        "^\/api": "/"
      }
    }
 }

```

My target is a youtube source videos I get from a python app in my backend. But every source beginning is the same except for this part:

```auto
"https://"xxxxxxxxxxx".googlevideo.com" 

```

For exemple:

```auto
"https://r1---sn-25ge7jsl.googlevideo.com"
"https://r2---sn-25ge7ns4.googlevideo.com"
"https://r8---sn-25ge7nsl.googlevideo.com"

```

I think regular expression would help me have a single target that would match any other targets.

This is the regex that would match the pattern:

> https://.+.googlevideo.com

So I tried this proxy with no luck:

```auto
{
    "\/api": {
      "target": "https:\/\/.+\.googlevideo\.com",
      "secure": true,
      "changeOrigin": true,
      "logLevel": "debug",
      "pathRewrite": {
        "^\/api": "/"
      }
    }
  }

```

I get a `Invalid escape character in string.json(261)` in VS Code and an Htpp 500 error in my console.

My question is: how should I implement this regex in my proxy?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [July 12, 2021, 9:23pm UTC](https://forum.freecodecamp.org/t/angular-use-regex-in-a-proxy/439957/2 "2021-07-12T21:23:17Z")

</div>

Closed on July 12, 2021, 9:23pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
