cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BTP Kyma node.js static resources

ThomasRyegaard
Explorer
0 Kudos
422

Hi,

I have created a node.js application and deployed it to SAP BTP Kyma. The application has a couple of static images in /public/images folder.

The images are loaded and displayed when I start the server locally, but the images are not loaded when I access the server deployed and running in BTP Kyma.

I don't know what I am missing, and hope someone have an idea on what to check.

/Thomas

Accepted Solutions (0)

Answers (1)

Answers (1)

vishalakshmi
Contributor
0 Kudos

Hello Thomas,

If your static images are not loading when you access your Node.js application deployed on SAP BTP Kyma, there could be several reasons for this issue.

  • Ensure that the file paths for your static images are correct in your HTML or CSS files. Since it works locally, make sure the paths are relative to the root of your application. For example, if your image is located in /public/images/image.jpg, your HTML should reference it as /images/image.jpg.
  • Confirm that the images were uploaded successfully to the /public/images folder on SAP BTP Kyma. Double-check the file names and extensions.
  • Check permissions for the /public/images
  • Verify that your Node.js application is properly configured to serve static files. In a Node.js application, you can use middleware like express.static to serve static files. Make sure you have this middleware configured correctly in your application code.

const express = require('express');

const app = express();

// Serve static files from the 'public' directory

app.use(express.static('public'));

  • Check if your application has a base URL configured that could affect the paths to your static files. If you have a base URL defined, make sure it is taken into account when constructing URLs for your images.
  • Add some logging statements in your Node.js application to log requests for static files.
  • If you are using a Content Delivery Network (CDN) in your SAP BTP Kyma setup, make sure that the CDN configuration is correct and that it is not causing issues with serving static files.
  • Ensure that the URLs you are using to access your deployed application on SAP BTP Kyma are correct and match the routes defined in your application.
  • Clear cache use different browser, check network errors

Thanks,

Lakshmi.