1

I'm using Expo with expo-router to build an app that I export as a static website using:

npx expo export --platform web --clear

I want to deploy the static site under a subpath, let's call it https://example.com/subpath.

However, after export, the generated HTML and JS bundles try to load assets from the root domain instead of the subpath:

❌ Tries to load:
https://example.com/_expo/static/js/...
https://example.com/assets/...
✅ But should load:
https://example.com/subpath/_expo/static/js/...
https://example.com/subpath/assets/...

Here is what I've tried :

  1. app.json : expo.web.publicPath = '/subpath/'
  2. web.config.json : output.publicPath='/subpath/'
  3. webpack.config.json :
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
module.exports = async function (env, argv) {
   const config = await createExpoWebpackConfigAsync(env, argv);
   config.output.publicPath = '/subpath/';
   return config;
};
  1. I even tried adding a router.config.js with module export = {basePath: '/subpath/',};

Nothing seems to be working, I've tried those solutions alone, combined, I don't get what I'm doing wrong. I can't find the right indications in the doc and obviously the last AI were not able to help neither.

1 Answer 1

0

I'm not sure how stable this is - because it's experimental - but this link seems to answer your need : Expo Router static export fails to respect publicPath and basePath when deployed under subpath

in app.json, putting experiments.baseUrl to "/subpath" should be working

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.