#Error EACCES: permission denied

32 messages · Page 1 of 1 (latest)

sick hare
#

I am trying to write in a file that is in my server in ./reqLog.txt, but it says that i do not have permision to do that, i tried moving it to the public folder but that doesn't work either, it works in my localhost, but in railway doesnt

regal flumeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

cinder laurelBOT
#

Project ID: N/A

nimble garden
#

does your project contain a public folder?

sick hare
#

Yes

#

But idealy this the file doesnt have to be in the public folder

#

Just in the app ./reqLog.txt

#

How can i give permission to do it? Or do i have to change the function that create the logs

nimble garden
#

wait why are you writing logs to a file anyway?

sick hare
#

For my company

#

We are adding security

#

And we want to know who did what

nimble garden
#

but what do you plan on doing with that file that you are writing to the container, there is no native way for you to grab that file from the container

sick hare
#

Sometimes there are problems, that someone delete o edited something that we do not wanted, so just i bring the server into my vscode and i will see there the file

#

And saw who did it

nimble garden
#

but thats not how it works, you are storing that file as a temp file in the container on railway, you cant just open that file up in vscode when its stored as a temp file in the container

#

please for the sake of scalability and best practices, dont save access logs to a temp txt file, send your logs to axiom or better stack or even https://railway.app/template/h_WWDP

sick hare
#

Ohhh

#

Axiom seems good

#

Let me try it

#

Thank you for the advice

nimble garden
#

axiom is very good, use their sdk

#

it should not take much work for you to refactor your code

sick hare
#

I am new in this things, adding middlewares slow down the application? Like if i ask for a GET users, and it has to pass in a logger middleware, validate middleare etc, that request is going to take longer?

nimble garden
#

dont log to axiom as a blocking event, do it asynchronously

sick hare
#

So like this it doesnt going to slow down the application?

nimble garden
#

looks like you are creating a new axiom client on every log event, you dont wanna do that.
it also looks like you are hardcoding the axiom token and dataset, please use environment variables!!
is the call to axiom.ingest sync or async? if its sync then it will slow down the api.

sick hare
#

Yes i am going to use enviroment variables, i just was seeing if it worked first jaja,
If axiom.ingest doesnt need await means that is sync?

nimble garden
#

not sure, I'm not a JavaScript dev, you would need to read axioms documentation or even have a quick peak at the source code for that function

sick hare
#

Okey, thank you, i liked axiom and it is easy to use

nimble garden
#

axiom is pretty good indeed