Merge pull request #169 from emrysal/feature/server-side-settings-redirect
Added redirects() entry to next.config.js, changed Settings url to /settings/profile
This commit is contained in:
		
						commit
						c867edcad8
					
				
					 3 changed files with 10 additions and 20 deletions
				
			
		| 
						 | 
					@ -59,7 +59,7 @@ export default function Shell(props) {
 | 
				
			||||||
                                            <Link href="/integrations">
 | 
					                                            <Link href="/integrations">
 | 
				
			||||||
                                                <a className={router.pathname.startsWith("/integrations") ? "bg-gray-700 text-white px-3 py-2 rounded-md text-sm font-medium" : "text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"}>Integrations</a>
 | 
					                                                <a className={router.pathname.startsWith("/integrations") ? "bg-gray-700 text-white px-3 py-2 rounded-md text-sm font-medium" : "text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"}>Integrations</a>
 | 
				
			||||||
                                            </Link>
 | 
					                                            </Link>
 | 
				
			||||||
                                            <Link href="/settings">
 | 
					                                            <Link href="/settings/profile">
 | 
				
			||||||
                                                <a className={router.pathname.startsWith("/settings") ? "bg-gray-700 text-white px-3 py-2 rounded-md text-sm font-medium" : "text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"}>Settings</a>
 | 
					                                                <a className={router.pathname.startsWith("/settings") ? "bg-gray-700 text-white px-3 py-2 rounded-md text-sm font-medium" : "text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"}>Settings</a>
 | 
				
			||||||
                                            </Link>
 | 
					                                            </Link>
 | 
				
			||||||
                                        </div>
 | 
					                                        </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,4 +22,13 @@ module.exports = withTM({
 | 
				
			||||||
  typescript: {
 | 
					  typescript: {
 | 
				
			||||||
    ignoreBuildErrors: true,
 | 
					    ignoreBuildErrors: true,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  async redirects() {
 | 
				
			||||||
 | 
					    return [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        source: '/settings',
 | 
				
			||||||
 | 
					        destination: '/settings/profile',
 | 
				
			||||||
 | 
					        permanent: true,
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +0,0 @@
 | 
				
			||||||
import { useRouter } from 'next/router';
 | 
					 | 
				
			||||||
import { signIn, useSession, getSession } from 'next-auth/client';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export default function Settings() {
 | 
					 | 
				
			||||||
    const [ session, loading ] = useSession();
 | 
					 | 
				
			||||||
    const router = useRouter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (loading) {
 | 
					 | 
				
			||||||
        return <p className="text-gray-400">Loading...</p>;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        if (!session) {
 | 
					 | 
				
			||||||
            window.location.href = "/auth/login";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    router.replace('/settings/profile');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return null;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in a new issue