3

When I try to go to https://site.con/categories/ I receive 403 Forbidden, but when I go to https://site.con/categories/sport everything fine, and else routes work fine. What could be the problem?

pages/categories/[id].js:

import { categories } from '../../data/categories';
import CategoryLayout from '../../layouts/CategoryLayout';

const Page = ({ category }) => {
  return <CategoryLayout data={category} />;
};
export async function getStaticPaths() {
  return {
    paths: Object.keys(categories).map(category => ({
      params: {
        page: category
      }
    })),
    fallback: false
  };
}

export async function getStaticProps({ params }) {
  const category = categories[params.id] || [];
  return {
    props: { category }
  };
}

export default Page;

1 Answer 1

2

faced the same problem. Look at your server - you probably don't have index.html inside the /categories folder.

I've found the solution here: How do I omit the html extension in next.js?

adding

module.exports = {
  exportTrailingSlash: true,
}

would create physical folder for every route in /pages with index.html instead of the route.html

Hope it helps you!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.