0

I'm sure I'm doing something blindingly obvious.. but I can't see what I'm doing wrong here..

I have a controller function

public function extsearch() {
    return redirect()->away('https://www.dropbox.com');
}

The route is fine as I've tested it with a view instead and it renders fine.. but this code gives me a "Page Not Found" error, and nothing in the logs.

From what I've seen this is the correct syntax for an external URL (obviously a dummy here). Laravel docs are typically somewhat opaque on this.

Edit:> digging around logs I finally noticed that nginx was complaining

[error] 27527#27527: *4089 connect() failed (111: Connection refused) while 
connecting to upstream, client: <hidden>, server: <hidden>, request: "OPTIONS 
/ HTTP/1.1", upstream: "http://[::1]:5984/", host: "<hidden>", referrer: 
"https://<hidden>/analytics/extsearch"
baradhili
  • 514
  • 1
  • 7
  • 27

2 Answers2

0

Try this.

return Redirect::to('https://www.dropbox.com');
Jasim Juwel
  • 736
  • 8
  • 19
  • well that syntax throws an error.. "production.ERROR: Class 'App\Http\Controllers\Analytics\Redirect' not found" Laravel 5.7 docs suggest the OP format is the correct one - https://laravel.com/docs/5.7/redirects – baradhili Dec 17 '18 at 04:01
  • well traced down that it might be nginx actually stopping the redirect for some weird reason... Once I figure that one out I'll post here – baradhili Dec 17 '18 at 04:37
  • use this for redirect use Illuminate\Support\Facades\Redirect; – Jasim Juwel Dec 17 '18 at 05:17
0

Seems it had little to do with Laravel - except that Laravel can't do a nice Nginx redirect if Nginx is already doing redirects itself..

With nginx/php-fpm, location header sometimes ignored by browser. Why?

gives most of the solution

baradhili
  • 514
  • 1
  • 7
  • 27