A sandbox refresh can leave the sandbox serving production’s robots.txt, so once its domain is set up again, the sandbox web store is open to every crawler. The fix is a small SuiteCommerce extension that adds noindex,nofollow on any hostname that isn’t production, checked in NetSuite’s SEO page generator as well as the browser. Don’t block the sandbox in robots.txt while any of its pages are still in Google, because a crawler that can’t fetch a page never sees its noindex.
I found this on a live SuiteCommerce Advanced store. Its sandbox web store had a public domain, no login, and the same catalogue and content as production. Nothing told search engines it wasn’t a second copy of the store.
Why a sandbox web store gets crawled
Three things line up, and none of them is a mistake on its own.
The domain is public. A sandbox web store needs a domain so people can test on it. Unless someone has turned on Password-protect Entire Site, anyone can load it, crawlers included.
Every URL answers. SCA is a single-page app, and the store I work on returns HTTP 200 and the app shell for any path at all. There, a crawler never hits a 404, so a wrong guess at a URL still gets a page.
The robots.txt is production’s. NetSuite serves robots.txt from the hosting root folder of the domain, which is a File Cabinet folder, and a refresh copies all configurations, data and customisations from production over the sandbox. A sandbox domain pointed at the same hosting root as production then serves production’s robots.txt. Mine was a byte-for-byte copy that allowed the whole catalogue and finished with a Sitemap: line pointing at production’s sitemap.
Check which robots.txt the domain actually serves
The account I found this on had two robots.txt files. One sat in Live Hosting Files and allowed everything. The other was a blocking file in a second hosting root that no domain read. Somebody had written the right file into the wrong folder.
Each domain is tied to one hosting root under Commerce > Hosting > Domains. Oracle’s domain setup page says to pick Live Hosting Files for a live site and Staging Hosting Files for a test site, which is probably how that orphaned file came about. The sandbox domain read Live Hosting Files, the same as production. Before you edit anything, fetch the file the domain serves and compare it with the one you’re about to change:
curl -s https://SANDBOX_DOMAIN/robots.txtWhy robots.txt and headers don’t fix it
Google says robots.txt is not a mechanism for keeping a web page out of Google. It controls crawling, not indexing. A blocked URL can still appear in results, just without a description. To keep a page out you need noindex or a password.
The usual way to send noindex without touching markup is the X-Robots-Tag header, and SCA’s configuration has an Add Headers to SSP Responses array that looks made for it. I tried it first. NetSuite dropped X-Robots-Tag without an error, while a Referrer-Policy row in the same array, on the same request, arrived at the browser. Oracle publishes two lists of blocked headers and X-Robots-Tag isn’t on either, so there’s nothing in the docs to work around short of a support case.
That leaves the robots meta tag in the page itself.
The fix: an extension that adds noindex off production
An extension keeps this out of the theme, deploys on its own and is activated per domain. Two files:
Workspace/NoIndex/
├── manifest.json
└── Modules/NoIndex/JavaScript/Vendor.NoIndex.jsThe manifest registers one entry point for all three applications, so the tag lands on the shop, the account pages and checkout:
{
"name": "NoIndex",
"fantasyName": "No Index",
"vendor": "Vendor",
"type": "extension",
"target": "SCA,SCS",
"target_version": {
"SCA": "",
"SCS": ""
},
"version": "1.0.0",
"description": "Adds a noindex,nofollow robots meta tag on every hostname that isn't production.",
"assets": {
"img": {
"files": []
},
"fonts": {
"files": []
},
"services": {
"files": []
}
},
"javascript": {
"entry_points": {
"shopping": "Modules/NoIndex/JavaScript/Vendor.NoIndex.js",
"myaccount": "Modules/NoIndex/JavaScript/Vendor.NoIndex.js",
"checkout": "Modules/NoIndex/JavaScript/Vendor.NoIndex.js"
},
"application": {
"shopping": {
"files": [
"Modules/NoIndex/JavaScript/Vendor.NoIndex.js"
]
},
"myaccount": {
"files": [
"Modules/NoIndex/JavaScript/Vendor.NoIndex.js"
]
},
"checkout": {
"files": [
"Modules/NoIndex/JavaScript/Vendor.NoIndex.js"
]
}
}
},
"suitescript2": {
"files": []
}
}The entry point does the work in mountToApp:
// Adds a noindex,nofollow robots tag on every hostname that isn't production.
// An allowlist rather than a sandbox check, so any new sandbox domain is covered.
define('Vendor.NoIndex', [
'Backbone'
], function (Backbone) {
'use strict';
// Every hostname your live store answers on, in lower case.
var PRODUCTION_HOSTS = ['YOUR_PRODUCTION_HOSTNAME'];
var TAG_ID = 'sandbox-noindex';
function isProduction() {
return PRODUCTION_HOSTS.indexOf(
String(window.location.hostname).toLowerCase()
) !== -1;
}
function addRobotsTag() {
if (document.getElementById(TAG_ID)) {
return;
}
jQuery('head').append(
'<meta id="' + TAG_ID + '" name="robots" content="noindex,nofollow">'
);
}
return {
mountToApp: function mountToApp() {
if (isProduction()) {
return;
}
addRobotsTag();
// SCA rewrites the meta tags between its enhanceMetaTags markers on
// every navigation. The tag lands outside those markers, and adding
// it again on each route puts it back if a view ever rewrites the
// whole head.
if (Backbone.history) {
Backbone.history.on('route', addRobotsTag);
}
}
};
});Two choices in there are deliberate.
It lists production, not the sandbox. A check for “sandbox” in the hostname misses the next preview domain somebody adds. An allowlist of production hostnames covers every other domain by default. The failure mode flips: forget a hostname and that domain gets noindexed, which on a sandbox is what you want. Put every hostname your live store answers on in PRODUCTION_HOSTS.
It runs again on every route. SCA navigates without page loads, and its own meta tag handling clears part of the head on each one. The tag goes in outside that range, so in practice it stays put. Re-adding it on route costs one getElementById call, and if a view ever rebuilt the whole head, the next navigation would put the tag back. The ID check stops duplicates.
What a crawler actually receives
The tag is added by JavaScript, so it isn’t in the raw HTML and curl won’t find it. Crawlers mostly don’t get the raw HTML anyway. SCA’s SEO page generator spots crawlers by user agent, runs the app on NetSuite’s side and sends them the result. Extensions run in there too. Oracle’s best practices page shows isPageGenerator() being checked inside mountToApp to keep code out of it, and this extension deliberately doesn’t check. When the page generator finishes, the tag is in the HTML the crawler gets.
It doesn’t always finish. The same page says it usually gives up after 10 seconds and returns what it has, marked 206 Partial Content. On the sandbox store I work on it fails today, and the HTML it returns has no robots tag. That HTML still loads the app’s scripts, so a crawler that renders the page boots the app and the extension adds the tag. Google documents that it reads a robots tag added by JavaScript. Bing doesn’t say either way, as far as I can find. So check what the page generator returns as well as what a browser shows. Both checks are at the end.
Deploy and activate
Deploy it with the extension developer tools. If you work against production and a sandbox, the config-swap scripts from my setup post make it one command per account:
npm run deploy:sandboxThen activate it on the sandbox domain only. Go to Commerce > Extensions > Extension Manager, click Edit next to the sandbox domain’s activation (or create a new activation for it), tick Active next to NoIndex on the Extensions tab, and click Activate. Nothing changes on the store until the activation finishes processing.
Deploy to production too, but activate only on the sandbox
This is the part that decides whether the fix survives a refresh, and it splits into two halves.
The files. A deployed extension lives in the File Cabinet and in records Extension Manager reads. If it exists only in the sandbox, the next refresh replaces all of that with production’s copy and the extension is gone. Deploy it to production as well (npm run deploy:production), and the refresh copies it back down with everything else.
The activation. Activations belong to a domain, and domains aren’t copied to the sandbox. After a refresh you set the sandbox domain up again and build its activation from scratch: the theme and every extension the sandbox runs, NoIndex included. Having the files already there means NoIndex is in that list instead of waiting on a redeploy. That saves more than it sounds: the same Oracle page says tokens aren’t copied either, so a redeploy after a refresh starts with authorising the developer tools against the sandbox again.
I haven’t been through a refresh with it yet, so the return trip follows from Oracle’s refresh pages rather than from something I’ve watched.
Don’t activate it on production. On the production domain the guard returns before doing anything, so an activation there buys nothing. It’s also the only way the code could ever load on your live store, and a missing hostname in the list would then noindex it. Activation is the first guard and the hostname list is the second. Keep both. On a 2019.1 or later Extension Management bundle, activation needs the Administrator role anyway, unless an admin has set up script deployments for other roles, so a developer who can deploy often can’t activate.
Don’t block the sandbox while its pages are in Google
This is where robots.txt bites back. Google is plain about it: for noindex to work, the page must not be blocked by robots.txt. A crawler that can’t fetch the page never reads the tag. If sandbox URLs are already indexed and you add Disallow: /, they can stay there as bare URLs with no description.
So the right robots.txt depends on where the sandbox is.
While sandbox pages are still indexed, let crawlers in so they can read the tag:
# Sandbox web store. Not for public indexing.
# Crawling is allowed so crawlers can read the noindex tag the NoIndex
# extension adds. Switch to "Disallow: /" once the sandbox URLs are gone
# from the index. A sandbox refresh replaces this file with production's.
User-agent: *
Allow: /Once they’re gone, block crawling:
# Sandbox web store. Not for public indexing.
# A sandbox refresh replaces this file with production's. Restore it
# after every refresh.
User-agent: *
Disallow: /Blocking is the better resting state because the extension only reaches pages the app renders. A PDF or image served from the sandbox domain can’t carry a meta tag, so robots.txt is all that keeps crawlers off those files.
To find out whether the sandbox is indexed, a Domain property in Search Console for your store’s domain already includes a sandbox subdomain of it, so the Pages report and URL Inspection work on sandbox URLs. Google warns that it may take months to revisit a page after you add noindex. If that’s too slow, the Removals tool hides URLs for about six months while the recrawl catches up.
After every sandbox refresh
The refresh resets most of this. The full list of what to redo is in What to redo after a NetSuite sandbox refresh. For noindex, in order:
- Set up the sandbox domain again, and check its hosting root is the folder you expect.
- Replace robots.txt in that hosting root with whichever version above fits.
- Create the sandbox domain’s activation again: the theme, every extension the sandbox runs, and NoIndex. Oracle says a domain’s first activation needs a cache invalidation request afterwards.
- If you need to deploy anything, authorise the developer tools against the sandbox first. The old token is gone.
- Run the check below on both stores.
Check it worked
Because the tag only exists after JavaScript runs, check the rendered page. Headless Chrome will render it and print the DOM. On macOS:
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
for url in https://SANDBOX_DOMAIN/ https://YOUR_PRODUCTION_HOSTNAME/; do
echo "$url"
"$CHROME" --headless=new --user-data-dir="$(mktemp -d)" --virtual-time-budget=20000 --dump-dom "$url" 2>/dev/null \
| grep -o '<meta[^>]*name="robots"[^>]*>'
doneThe sandbox should print the tag and production should print nothing:
https://SANDBOX_DOMAIN/
<meta id="sandbox-noindex" name="robots" content="noindex,nofollow">
https://YOUR_PRODUCTION_HOSTNAME/--virtual-time-budget gives the app time to boot before the DOM is dumped, and the throwaway profile keeps it clear of a Chrome you already have open. Any robots tag production prints is worth reading, but one with noindex in it is an emergency.
Then check what the page generator hands crawlers. Oracle’s debug log comes back when you add seodebug=T to a store URL:
curl -s "https://SANDBOX_DOMAIN/?seodebug=T" | grep -o '<meta[^>]*name="robots"[^>]*>'If that prints the tag, crawlers on the page generator path get it. If it prints nothing, open view-source:https://SANDBOX_DOMAIN/?seodebug=T in a browser and read the log at the bottom. “Error in SEO Page Generation”, or a response that took around 10 seconds, means the page generator didn’t finish, and only crawlers that render JavaScript themselves will see the tag. Run the same check on production now and then. Oracle warns that when it fails, partial content may be served to search engines, and on production that’s your live store.
For Google’s own view, URL Inspection’s live test shows the HTML Googlebot rendered. For the whole site rather than one page, use a crawler with JavaScript rendering switched on. Without it, a crawler reports whatever HTML NetSuite hands it, which may not carry the tag.
This post is part of the NetSuite SEO cluster. The crawlers and audit tools I use are on the resources page.