From 90b2daf8c79190ed748c93736dc7a91b7a31a457 Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Mon, 18 Jan 2021 10:43:25 +0100
Subject: [PATCH] generating URLs only working in non production environment

---
 routes/web.php | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/routes/web.php b/routes/web.php
index 7f5f34b..af856b8 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -27,14 +27,15 @@ Route::get('/', 'ProxyController@proxyPage')->name('proxy-wrapper-page');
 Route::get('p', 'ProxyController@proxy')->name('proxy');
 
 Route::post('/', function (Request $request) {
-    $validatedData = $request->validate([
-        'url' => 'required|url|max:255',
-    ]);
-    $url = $request->input('url', 'https://metager.de');
-    $password = md5(env('PROXY_PASSWORD') . $url);
-    $url = base64_encode(str_rot13($url));
-    $target = urlencode(str_replace("/", "<<SLASH>>", $url));
-    return redirect(action('ProxyController@proxyPage', ['password' => $password, 'url' => $target]));
+    if (env("APP_ENV", "") !== "production") {
+        $validatedData = $request->validate([
+            'url' => 'required|url|max:255',
+        ]);
+        $url = $request->input('url', 'https://metager.de');
+        return redirect(\App\Http\Controllers\ProxyController::generateProxyWrapperUrl($url));
+    }else{
+        abort(400);
+    }
 });
 
 /**
-- 
GitLab