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

sospedra picture sospedra  路  3Comments

olifante picture olifante  路  3Comments

lixiaoyan picture lixiaoyan  路  3Comments

pie6k picture pie6k  路  3Comments

timneutkens picture timneutkens  路  3Comments