Next.js: Cannot access static inside the dynamic route directory

Created on 31 Aug 2019  路  1Comment  路  Source: vercel/next.js

Bug report

Describe the bug

Static directory mapping doesn't work inside the dynamic route directory

To Reproduce

  1. Go to 'nextjs/examples'
  2. Download dynamic routing example
  3. Add a static folder and put any image inside that folder
  4. Try accessing the image on posts/[id].js with static mapping

I have to do a '../static/img.png' to make it work inside the post directory but
if the component is being imported from somewhere else and is used at multiple places(in other pages), there is no work around for that.

Expected behavior

static should also work inside the dynamic routes directory.

System information

  • OS:linux
  • Version of Next.js: 9

Most helpful comment

Static mapping being? In general it's best to provide a full reproduction, now we have to guess what you did in particular. I assume you added src="static/img.png" instead of src="/static/img.png" 馃

>All comments

Static mapping being? In general it's best to provide a full reproduction, now we have to guess what you did in particular. I assume you added src="static/img.png" instead of src="/static/img.png" 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

renatorib picture renatorib  路  3Comments

knipferrc picture knipferrc  路  3Comments

YarivGilad picture YarivGilad  路  3Comments

jesselee34 picture jesselee34  路  3Comments