storyblok / storyblok-astro

Astro SDK for Storyblok CMS
MIT License
164 stars 29 forks source link

404 error : {"message":"Not Found","status":404,"response":"This record could not be found"} #800

Closed vvaldesc closed 7 months ago

vvaldesc commented 7 months ago

storyblok.com

404 not found error when loading mainpage ( localhost:XXXX/ )

[ERROR] {"message":"Not Found","status":404,"response":"This record could not be found"}


Expected Behavior

Load astro website mainpage correctly

Current Behavior

Error 404 not found: (Only happening when i try to go to '/' (index astro file url by default). Not when i go to an uknown url)

XX:XX:XX [ERROR] {"message":"Not Found","status":404,"response":"This record could not be found"} Hint: To get as much information as possible from your errors, make sure to throw Error objects instead of object. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error for more information. Stack trace: at XXXXXXXX\astro\dist\core\errors\utils.js:64:19 [...] See full stack trace in the browser, or rerun with --verbose.

Steps to Reproduce

my dependencies:

"dependencies": { "@astrojs/check": "^0.5.10", "@astrojs/react": "^3.3.2", "@astrojs/svelte": "^5.4.0", "@astrojs/tailwind": "^5.1.0", "@storyblok/astro": "^4.0.5", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", "astro": "^4.7.1", "astro-icon": "^1.1.0", "astro-meta-tags": "^0.3.0", "astro-seo": "^0.8.3", "axios": "^1.6.8", "eslint-plugin-react": "^7.34.1", "react": "^18.3.1", "react-dom": "^18.3.1", "svelte": "^4.2.15", "tailwindcss": "^3.4.3", "typescript": "^5.4.5" }, "devDependencies": { "@iconify-json/mdi": "^1.1.66", "@vitejs/plugin-basic-ssl": "^1.1.0" }

  1. Introduce storyblok to your already created astro project.
  2. From your storyblok space delete your default mainpage 'Home' and create a new one called differently 'Main'
  3. Create new page with an existent slug on your web
  4. Restart your computer
  5. run dev and go to your astro mainpage ('/')

I think this error is due to the url '/' not being supported by storyblok and it returns an exception that is somehow not well interpreted by 'createSafeError'. This could be fixed with a simple redirect, but I'd like to fix it at the storyblok level. I'm a beginner in this CMS and I don't know if there is an option to define the path '/' for the mainpage, since it is the one that astro defines for the index.

Related issues: https://github.com/storyblok/storyblok-astro/issues/574 (Fixed by storyblok redirection) https://github.com/storyblok/storyblok-astro/issues/169

vvaldesc commented 7 months ago

SOLVED: Adding redirection to my astro website

Astro provides url mapping.

in astro.config.mjs i added:

export default defineConfig({
  redirects: {
    '/home': '/'
  },
//more configuration
});

By redirecting 'home' (storyblok mainpage) to '/' (Astro default index url) i can use the graphic editor in storyblok.