The functions folder is recognized but not being applied

For Workers & Pages, what is the name of the domain?

still haven’t deployed

What is the error number?

it doesn’t produce an error in fact it tells me ‘Compiled Worker successfully’

What is the issue or error you’re encountering

as I have pointed out ‘Compiled Worker successfully’ is the message I recieve in the terminal yet it doesn’t apply it when openning the pages in my local enviroment

What steps have you taken to resolve the issue?

I have tried messing with the command moving directories nothing is working and it’s driving me to insanity

We don’t have enough information to know what’s going on. What is in your /functions directory, and what do you mean by “it doesn’t apply”? What happens and what are you expecting to happen?

like the server side code doesn’t work

like on a specific page if the user isn’t logged in it redirects the user to the login page and that isn’t happening and it’s not an issue with my code as on specific page I have an on post request function and when I try to post it returns 405 method not allowed

my directory structure looks. like this
root:
public:
static assets
functions:
server-side code
wrangler.jsonc
and the root is where I run wrangler pages dev

wrangler.jsonc looks like this bindings ommited:
{
“name”: “scents”,
“pages_build_output_dir”: “public”,
“assets”: {
“directory”: “public”
}
}

do you need anything else

I am using the latest version of wrangler

What is in your functions directory? Is the code running at all? How are you calling it? Are you using the right route? What’s the path to your code file and what URL are you using to call it?

What’s the output when you run wrangler?

@i40west Here is the link to a github repo containing some of the files of my project

It works for me, including function invocation. I don’t have the database, obviously, so it throws an error, but it does get called when I post to the /login/ route.

One thing I notice is that in your wrangler.jsonc your database_name and binding are both DB, but in your code you’re calling it as context.env.scentsdb. The database_name should be whatever the name actually is for your database (presumably scentsdb), and the binding is whatever you want to call it in your code. if you want to call it as context.env.scentsdb then the binding would need to be scentsdb.

2 Likes

@i40west I have good news and bad news good news is that that /login/ is now working as intended bad news is that the root of the website functions isn’t being executed

@i40west I have updated the github repo with the new code

You’re not exporting the functions in functions/index.js.

async function onRequestGet(context){

should be

export async function onRequestGet(context){

1 Like

tysm I will always ask my questions here it’s much much better than stackoverflow

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.