-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the path to the static
folder
#8769
Comments
This ability is also relevant for other plugins such as next-i18next. Here the static folder / in the future perhaps the public folder includes translation files which are required to load from a deployed, server near function. Hopefully one of the main contributors can shine some light on that issue, thx. |
I don't know if I understand your issue correctly. Files are served with the static directory as described here. You can just use |
I would like to read the file using |
Then read the file relative to your next.js root project "static" is fixed. |
If I use a relative path, then if I move the file containing the code, I need to modify the code of the file for example. If my code is in a package, then the path is different, etc... This is not ideal from my point of view. |
Duplicate of #8251 (comment) |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Feature request
Is your feature request related to a problem? Please describe.
I would like to get the path to the static folder.
Such a function / variable is built-in in other frameworks like Laravel: https://laravel.com/docs/6.x/helpers#method-public-path
What I tried
I tried to get it with
__dirname
or./
orprocess.cwd()
, it works but the command depends either on the location of the file containing it or the location where the script is executed.Hence, this is not convenient, because I have to modify my command if I move my file or execute the script from another place. For example, my app works locally but not on production using Now.
The text was updated successfully, but these errors were encountered: