4

Router configuration:

const routes =
[
    {
        path: '/',
        component: Layout,
        onEnter: sessionFilter,
        indexRoute:
        {
            component: ActivityIndex,
            onEnter: sessionFilter
        },
        childRoutes:
        [
            {
                path: 'login',
                component: LoginPage
            },{
                path: 'activity-new',
                component: ActivityNew,
                onEnter: sessionFilter
            },{
                path: 'activity-edit/:id',
                component: ActivityEdit,
                onEnter: sessionFilter
            }
        ]
    }
];

ReactDOM.render(<Router routes={routes} history={browserHistory}/>, Node);

Nginx configuration:

server {
    listen 5002;
    location / {
        root www/bc;
        index index.html;
        try_files $uri $uri/ /index.html;
    }
}

All files transpiled with babel(webpack). It works fine when I access http://server:5002/something but throws an Unexpected token < if I access http://server:5002/something/1 or http://server:5002/something/.

When I looked at the Sources tab in the Developer Tools I noticed that the js file has been returned with the index.html as its content which is caused by the Request URL pointing to http://server:5002/something/app.js instead of http://server:5002/app.js. Do I need to add something to the configuration to solve this issue?

1 Answer 1

3

I think the problem in src path of your JS file in script tag.

Instead of <script src="app.js"></script>, use: <script src="/app.js"></script>

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.