Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

temi's avatar
Level 5

Blank Page after redirect

Hello Forum, I have a form to create a blog post. It successfully creates the post in the DB. The following redirect gives me a blank page. But if I fetch the url via browser it works

So the create method makes a redirect to /posts => blank page if I fetch it via browser /posts I get the page

by the way why it redirects to /posts I would expect a redirect('/'); actually redirects to /

my PostsController


<?php

namespace App\Http\Controllers;

use App\Posts;
use Illuminate\Http\Request;

class PostsController extends Controller
{
    public function __construct ()
    {

        $this -> middleware('auth', ['except' => 'index']);
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('posts.index');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('posts.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        Posts::create(request(['title', 'body']));
        
        redirect('/'); 
    }

    
    /**
     * Display the specified resource.
     *
     * @param  \App\Posts  $posts
     * @return \Illuminate\Http\Response
     */
    public function show(Posts $posts)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Posts  $posts
     * @return \Illuminate\Http\Response
     */
    public function edit(Posts $posts)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Posts  $posts
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Posts $posts)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Posts  $posts
     * @return \Illuminate\Http\Response
     */
    public function destroy(Posts $posts)
    {
        //
    }
}

my Routes


<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Auth::routes();

Route::get('/', 'HomeController@index');
Route::resource('posts', 'PostsController');

I have no idea why.

Thanks in advance Mike

0 likes
2 replies
thomaskim's avatar
Level 41

@temi You are forgetting the return statement.

Change redirect('/'); to return redirect('/');

1 like
Snapey's avatar

you need to return redirect()

1 like

Please or to participate in this conversation.