OxfordRSE / gutenberg

https://oxfordrse.github.io/gutenberg
BSD 3-Clause "New" or "Revised" License
5 stars 7 forks source link

Conflicting public file and page route for /material causes server error #251

Open ansarrafique opened 4 months ago

ansarrafique commented 4 months ago

Bug

I encountered a Server Error while generating the page after clicking the "View the teaching materials" button on the landing page (home page). The error message indicates a conflict between a public file and a page file for the path /material.

Error Message

Error: A conflicting public file and page file was found for path /material https://nextjs.org/docs/messages/conflicting-public-file-page

This error happened while generating the page. Any console logs will be displayed in the terminal window. Call Stack DevServer.handleRequestImpl

Steps to Reproduce

  1. Clone the repository.
  2. Install the required dependencies.
  3. Start the local development server using yarn dev.
  4. Go to the home page.
  5. Click on the "View the teaching materials" button.

Expected Behavior

The application should correctly serve the teaching materials page without conflicts and without generating a server error.

System Information

Additional Context

This error occurs specifically when navigating from the home page to the teaching materials page using the button provided. The conflict seems to be between a static file in the public directory and a dynamic route in the pages directory both named material.

alasdairwilson commented 4 months ago

Thanks for this bug report,

Do you have markdown material in the .material folder? IF not, run yarn pullmat to load the default material from the hpc-universe repo - if you wish to change this: this is configured in the yaml template in the config (https://blog.oxrse.uk/gutenberg/ has the details I think). If you have done this, and it still isn't working then let me know!

If this is the case, it is not ideal really that we get a crash here rather than a message on the /material page.

ansarrafique commented 3 months ago

Yes, I do have the markdown material in the .material directory. I've managed to fix the problem by renaming the material to material-public in the public directory. This fixes the problem, but I am not sure if it's the right way?

ansarrafique commented 3 months ago

@alasdairwilson Could you please confirm if this is the right approach and if it's safe to proceed?

alasdairwilson commented 3 months ago

I was able to recreate this by using windows, I kinda expected it to be a symbolic link issue because those do behave differently in windows and indeed it is.

Renaming would do nothing really because it is just a dead file in windows, I found that just deleting the symbolic link didn't seem to cause a problem with the build, the static pages are still built correctly however I can't remember the exact reason why the link is there.... so I would be reluctant to delete it incase it is part of some next wizardry for performance reasons.

You can however create an equivalent symbolic link using a powershell prompt and navigating to /public then:

New-Item -ItemType SymbolicLink -Path "material" -Target "../.material"

Which works identically, as far as my testing shows, to the existing one.

Also having seen the performance on native windows I would highly recommend using docker, there is a compose file for you to use to build the whole project or you can just build the dockerfile for just the node application, almost certainly will be more convenient for you!