How to access file from netlify SSR function

I am trying to access a css file present at root .next directory

with below code
const criticalCSSPath = path.join(process.cwd(), ‘functions’, ‘optiBootstrap.css’);
const criticalCSS = fs.readFileSync(criticalCSSPath, ‘utf8’);

but I am getting below error

Jul 5, 01:27:56 AM: 13a2d169 INFO render >> RootLayoutJul 5, 01:27:56 AM: 13a2d169 ERROR Error: ENOENT: no such file or directory, open ‘/var/task/functions/optiBootstrap.css’
at Object.openSync (node:fs:596:3)
at Object.readFileSync (node:fs:464:35)
at RootLayout (/var/task/.next/server/chunks/9770.js:1:3295) {
errno: -2,
syscall: ‘open’,
code: ‘ENOENT’,
path: ‘/var/task/functions/optiBootstrap.css’
}

I see error is in netlify SSR function - https://dev.1millionresume.com/.netlify/functions/___netlify-handler

Can netlify team guide me on this?

@kunal.saxena.kunal The static site files and functions are not deployed to the same location.

The static files are deployed to the CDN.
The functions deployed as AWS lambda’s.

The function does not inherently have access to the files on the CDN.

You would need to ensure optiBootstrap.css is included in the functions bundle.

See included_files here:
https://docs.netlify.com/configure-builds/file-based-configuration/#functions

@nathanmartin Thank you so much. It worked for me after referring to link and blog post.