3

I have installed sitecore 10.0.3 on premise on dev server (remote desktop) and created next.js Jss app and connected the app with sitecore, now i have the app running and i can access the site from inside remote desktop, also i can access the sitecore CMS from out side the remote desktop but i can not access the site or experience editor for pages from out side the remote deskop.

how shall I deploy the app to make the site public from out side the remote desktop?

note : I am using next self rendering host loaclhost:3000 enter image description here

2 Answers 2

1

You can deploy NextJS to IIS 1- install URLRewrite and IISNode 2- add web.config

    <configuration>
  <system.webServer>    
    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>

    <iisnode node_env="production" nodeProcessCommandLine="&quot;C:\Program Files\nodejs\node.exe&quot;" interceptor="&quot;%programfiles%\iisnode\interceptor.js&quot;" />

  </system.webServer>
    <location path="" overrideMode="Deny">
        <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
        </system.webServer>
    </location>
    <system.net>
        <mailSettings>
            <smtp from="">
                <network defaultCredentials="false" host="" password="" port="25" userName="" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

3- add server.js

{ createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const cors = require('cors');

require('dotenv').config();

const dev = process.env.NODE_ENV !== 'production'
const port = process.env.PORT || 3000;
const app = next({ dev })

const handle = app.getRequestHandler()

const corsOptions = {
  origin: process.env.SITECORE_API_HOST,
};

app.prepare().then(() => {
    
  createServer((req, res) => {
        
        const parsedUrl = parse(req.url, true)
        const { pathname, query } = parsedUrl       
        
        if (pathname === '/a') {
          app.render(req, res, '/a', query)
        } else if (pathname === '/b') {
          app.render(req, res, '/b', query)
        } else {
          handle(req, res, parsedUrl)
        }
  }).listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})
0

You should be able to access the site via the IP address of your remove desktop network connection. Let's say your IP is 192.168.1.2 - you can access http://192.168.1.2:3000.

If you want to use a url with a meaningful name, then add a hosts entry pointing to that IP address, you will still need to add the port to the url. e.g http://mynextjssite.localhost:3000

1
  • I have tried this but not working gives me "This page isn’t working 20.216.18.205 didn’t send any data." Commented Jan 4 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.