Angular: use RegEx in a proxy

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

This is my proxy:

{
    "\/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:

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

For exemple:

"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:

{
    "\/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?

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