Rendering Non-React Component (HTML/JSON page) #14991
-
Hey guys, I'm creating a Salesforce Custom UI and the conventions for this as indicated in their official docs is to have |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
If index.html and config.json are static, you can put those files in the public directory (https://nextjs.org/docs/basic-features/static-file-serving) and they will be served as /index.html and /config.json If you need them to be dynamic, then you can create pages/index.html.js and pages/config.json.js and return the response from there. You can set the content type to be JSON in getInitialProps (or getServerSideProps) as shown below.
We use the above implementation for dynamic sitemaps. |
Beta Was this translation helpful? Give feedback.
-
Thank you @srikanth912 for your help! Fortunately, I found this little tweak to work excellently:
This is a working example // pages/config.json.js
const sampleConfigData = [{"id":1,"first_name":"Petronia","last_name":"DelaField","email":"pdelafield0@state.gov","gender":"Female","ip_address":"200.86.172.105"},
{"id":2,"first_name":"Kendall","last_name":"Shilladay","email":"kshilladay1@who.int","gender":"Male","ip_address":"53.26.234.195"},
{"id":3,"first_name":"Shelia","last_name":"Jenoure","email":"sjenoure2@acquirethisname.com","gender":"Female","ip_address":"105.195.252.114"},
{"id":4,"first_name":"Cherida","last_name":"Cronkshaw","email":"ccronkshaw3@telegraph.co.uk","gender":"Female","ip_address":"59.49.88.149"},
{"id":5,"first_name":"Bibby","last_name":"Betham","email":"bbetham4@sitemeter.com","gender":"Female","ip_address":"38.115.1.6"}];
export default function configPage() {
return JSON.stringify(sampleConfigData);
} The above script can now be accessed, with the right data, at |
Beta Was this translation helpful? Give feedback.
-
I've never done this before, but how about using |
Beta Was this translation helpful? Give feedback.
-
Update: // next.config.js
module.exports = {
async rewrites() {
return [
{
source: '/:integrationKey/activities/config.json',
destination: '/api/:integrationKey/activities/config.json',
},
];
}
}; |
Beta Was this translation helpful? Give feedback.
Thank you @srikanth912 for your help!
Fortunately, I found this little tweak to work excellently:
Steps:
.js
at the end of thepages/config.json
file.This is a working example